By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,796 Members | 1,148 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,796 IT Pros & Developers. It's quick & easy.

Level by level traversal of BST

P: 2
In java, how can we traverse a binary search tree level by level ?
Sep 4 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 10K+
P: 11,448
In java, how can we traverse a binary search tree level by level ?
You need a queue for that: first you push the root and you repeatedly pop a
current node, process it and push its children to that queue again; all that
until the queue is empty.

You'd do it the same in C, C++, Java, SmallTalk or whatever.

kind regards,

Jos
Sep 4 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.