Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of Tree Traversal in java #149

Merged
merged 10 commits into from
Jun 29, 2018
Prev Previous commit
Next Next commit
Moved temp variable in bfsQueue()
xam4lor authored Jun 29, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 8467c5ff7b30a552792a0112699016ab40df13e7
4 changes: 1 addition & 3 deletions chapters/tree_traversal/code/java/Tree.java
Original file line number Diff line number Diff line change
@@ -82,11 +82,9 @@ public void bfsQueue() {
Queue<Node> queue = new PriorityQueue<Node>();
queue.add(this.root);

Node temp;

while (queue.size() != 0) {
System.out.println(queue.peek().id);
temp = queue.poll(); // return null if the queue is empty
Node temp = queue.poll(); // return null if the queue is empty

if (temp != null) {
for (Node c : temp.children) {