Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int minHeight(node root) {
- if(root == null) return 0; //pt cazul nada
- if(root.left == null && root.right == null)
- return 1;
- else {
- int l = MAX_VALUE, r = MAX_VALUE;
- if(root.left != null)
- l = minHeight(root.left);
- if(root.right != null)
- r = minHeight(root.right);
- return 1 + min(l,r);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement