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
An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?
State two uses of pointers in C?
What is #include stdio h?
What is a stream water?
What is meant by keywords in c?
What is a rvalue?
What is the significance of an algorithm to C programming?
What is strcpy() function?
What is the use of clrscr?
Are bit fields portable?
What is hashing in c?
Explain what is a const pointer?
What is nested structure with example?
Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
Does free set pointer to null?