Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
why we use queues data structure for level order traverse?
#1
In level-order traversal, we start from the first level, print all nodes from left to right and move to the next level. We continue it untill we reach last level.
Now as you know queue is FIFO (First In First Out) structure, it helps us in level-order traversal. Lets see how?
The procedure is to insert all nodes on first level into queue, then dequeue node, print it and inserts its left and right child nodes into queue. Continue untill queue is empty.

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  what is in order successor? in C++ 2012 Vuhelper 0 2,592 01-04-2012, 11:08 PM
Last Post: Vuhelper
  Abstract data type (ADT) in C++ 2012 Vuhelper 0 7,107 01-04-2012, 10:34 PM
Last Post: Vuhelper
  call by value, call by reference,call by pointer in data structure 2012 Vuhelper 0 4,334 01-04-2012, 10:28 PM
Last Post: Vuhelper
  Balance of the AVL tree im Data structure 2012 Vuhelper 0 1,903 01-04-2012, 10:27 PM
Last Post: Vuhelper
  the uses of queues and stacks? the application of binery tree? in C++ 2012 Vuhelper 0 1,686 01-04-2012, 10:24 PM
Last Post: Vuhelper
  binary tree,the pre and post order traversal have the same method? is in both methods Vuhelper 0 1,785 01-04-2012, 10:23 PM
Last Post: Vuhelper
  Linklist Data Structure Vuhelper 0 1,902 11-05-2011, 05:11 PM
Last Post: Vuhelper
  Boolean data problem in c++ 2011-12 Vuhelper 0 897 08-27-2011, 08:57 PM
Last Post: Vuhelper
  Overloaded >> operator not reading more than first line from data file in c++ 2011 Vuhelper 0 917 07-23-2011, 05:38 PM
Last Post: Vuhelper
  Read data from file into arrays in c++ 2011 Vuhelper 0 917 07-20-2011, 10:58 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)