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


Please Help Members By Posting Answers For Below Questions

Differentiate between a structure and a union.

773


how many errors in c explain deply

1637


What is masking?

646


What is "Hungarian Notation"?

647


What was noalias and what ever happened to it?

601






What is the size of enum in bytes?

598


Can a function argument have default value?

680


explain what is fifo?

645


What are header files? What are their uses?

648


Explain a file operation in C with an example.

669


how can I convert a string to a number?

606


Give basis knowledge of web designing ...

1586


What is the difference between a function and a method in c?

571


What the different types of arrays in c?

620


What is the need of structure in c?

572