Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
source coding is a little complex
  • Loading branch information
JayH2018 authored Aug 28, 2018
commit 28deddd5d78064274b76df56126c9a72163ad361
14 changes: 5 additions & 9 deletions DataStructures/Trees/LevelOrderTraversal.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,10 @@ int height(Node root)
return 0;
else
{
/* compute height of each subtree */
int lheight = height(root.left);
int rheight = height(root.right);

/* use the larger one */
if (lheight > rheight)
return(lheight+1);
else return(rheight+1);
/**
* return the larger one;
*/
return Math.max(height(root.left),height(root.right)) + 1;
}
}

Expand Down Expand Up @@ -75,4 +71,4 @@ public static void main(String args[])
System.out.println("Level order traversal of binary tree is ");
tree.printLevelOrder();
}
}
}