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 are the main characteristics of c language describe the structure of ac program?
#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??
What is #include cctype?
What is sizeof int?
What is difference between far and near pointers?
What is 2 d array in c?
What does typeof return in c?
Explain what is the best way to comment out a section of code that contains comments?
In a header file whether functions are declared or defined?
In C programming, what command or code can be used to determine if a number of odd or even?
Explain the use of function toupper() with and example code?
What is volatile variable in c?
What are the various types of control structures in programming?
How many levels of pointers have?
What is the purpose of main() function?