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 structure and a union.
how many errors in c explain deply
What is masking?
What is "Hungarian Notation"?
What was noalias and what ever happened to it?
What is the size of enum in bytes?
Can a function argument have default value?
explain what is fifo?
What are header files? What are their uses?
Explain a file operation in C with an example.
how can I convert a string to a number?
Give basis knowledge of web designing ...
What is the difference between a function and a method in c?
What the different types of arrays in c?
What is the need of structure in c?