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 the best way of making my program efficient?
What are the two forms of #include directive?
What is the difference between new and malloc functions?
Are pointers integers in c?
Which built-in library function can be used to match a patter from the string?
Explain how can I convert a string to a number?
Why do we use header files in c?
How can I find the modification date and time of a file?
What is the collection of communication lines and routers called?
What is boolean in c?
Is it valid to address one element beyond the end of an array?
What is the acronym for ansi?
Write a program to reverse a string.
How will you divide two numbers in a MACRO?
a program that can input number of records and can view it again the record