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
What is f'n in math?
What is the right type to use for boolean values in c? Is there a standard type?
What is #include stdlib h?
What are the different data types in C?
Write a code to generate a series where the next element is the sum of last k terms.
What is difference between structure and union in c programming?
How we can insert comments in a c program?
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 with dynamically allocation of variable.
hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?
what does static variable mean?
a function gets called when the function name is followed by a a) semicolon (;) b) period(.) c) ! d) none of the above
How do you convert strings to numbers in C?
Why we write conio h in c?
Is javascript based on c?