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

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?

1195


State two uses of pointers in C?

1017


What is #include stdio h?

1072


What is a stream water?

1142


What is meant by keywords in c?

1040


What is a rvalue?

1149


What is the significance of an algorithm to C programming?

1013


What is strcpy() function?

1097


What is the use of clrscr?

1067


Are bit fields portable?

1116


What is hashing in c?

1107


Explain what is a const pointer?

1047


What is nested structure with example?

1031


Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

1175


Does free set pointer to null?

965