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
How would you obtain the current time and difference between two times?
How to find a missed value, if you want to store 100 values in a 99 sized array?
What is getch () for?
What are the rules for identifiers in c?
What is void c?
Difference between pass by reference and pass by value?
HOW TO SOLVE A NUMERICAL OF LRU IN OS ??????
void main(int n) { if(n==0) return; main(--n); printf("%d ",n); getch(); } how it work and what will be its output...............it any one know ans plz reply
Write a program of advanced Fibonacci series.
Explain how does free() know explain how much memory to release?
What is optimization in c?
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.
Explain union.
Why isn't any of this standardized in c? Any real program has to do some of these things.
What is the heap?