Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 for loop and a while loop? What are it uses?

1192


What is difference between array and pointer in c?

1100


What is typedef?

1436


I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.

2243


How a string is stored in c?

1076


What is the use of ?

1044


What is #pragma statements?

1105


Explain how can I pad a string to a known length?

1201


Explain goto?

1167


What is the use of a semicolon (;) at the end of every program statement?

1518


‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.

2350


An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above

1185


What is exit() function?

1030


what are bit fields? What is the use of bit fields in a structure declaration?

2137


what is recursion in C

1075