How would you print out the data in a binary tree, level by
level, starting at the top?
Answer Posted / ds
Use a queue to achieve this.
1. push root to queue
2. if root!=NULL, pop root and print data.
3. visit left child and right child of root and push them to
queue
4. pop leftchild from queue , print data, push left and
right child.
5. pop rightchild from queue, print data, push left and
right child.
6. carry on till queue is empty.
| Is This Answer Correct ? | 34 Yes | 7 No |
Post New Answer View All Answers
Differentiate between a for loop and a while loop? What are it uses?
What is difference between array and pointer in c?
What is typedef?
I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.
How a string is stored in c?
What is the use of ?
What is #pragma statements?
Explain how can I pad a string to a known length?
Explain goto?
What is the use of a semicolon (;) at the end of every program statement?
‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.
An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above
What is exit() function?
what are bit fields? What is the use of bit fields in a structure declaration?
what is recursion in C