print a binary tree level by level


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: print a binary tree level by level

  1. #1
    Join Date
    May 2006
    Posts
    1

    print a binary tree level by level

    Could someone help me out in printing a binary tree level by level, knowing its depth??

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    You would perform a breadth first search -

    go to root, put it into a queue
    whle the queue is not empty,
    pop the root node off the queue, print, visit each of its children, pushing them onto the queue
    pop the first child off the queue, print, visit each of its chidren, pushing them onto the queue
    pop the next child,
    etc.

Similar Threads

  1. quick basic codes conversion
    By oranged in forum VB Classic
    Replies: 2
    Last Post: 07-19-2006, 07:50 AM
  2. Replies: 2
    Last Post: 04-18-2006, 06:12 PM
  3. Replies: 4
    Last Post: 12-05-2005, 07:58 PM
  4. Binary Tree Help
    By TheJVM_1970 in forum Java
    Replies: 2
    Last Post: 12-05-2005, 01:23 AM
  5. Replies: 2
    Last Post: 03-24-2000, 02:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center