FW - check whether tree is balanced or not - find the max and min of one tree- 2013年12月18日13:12:04
2013-12-19 02:12
656 查看
public static int getMaxdepth(Node root) { if(root!=null) {// max the left and right of the tree; the max is the max of left and right tree return 1+Math.max(getMaxdepth(root.left_child), getMaxdepth(root.right_child)); } else {// if it is null return 0; return 0; } } public static int getMindepth(Node root) { if(root!=null) { return 1+Math.min(getMindepth(root.left_child), getMindepth(root.right_child)); } else { return 0; } }
相关文章推荐
- The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
- FW:Could not change the bindings for orchestration---One or more instances of the orchestration still exist
- check a tree is balanced or not
- Could not load file or assembly ‘AjaxControlToolkit’ or one of its dependencies. The parameter is incorrect. (Exception
- The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.报该错误的一种原因。
- Could not load file or assembly ‘AjaxControlToolkit’ or one of its dependencies. The parameter is incorrect.
- How To Check Whether Physical Standby is in Sync with the Primary or Not?
- CareerCup Find whether a given number is a perfect square or not.(Addition and Subtraction only)
- 判断是否为完全二叉树 Check whether a binary tree is a complete tree or not
- Could not load file or assembly "xxx" or one of its dependencies. The system cannot find the file sp
- Check whether a given Binary Tree is Complete or not 解答
- Check if the given binary tree is BST or not.
- [INS-41107]eth0 selected for one or more of the public or private interfaces is not on a shared subn
- Could not load file or assembly 'App_Web_xxxx' or one of its dependencies. The system cannot find the file specified.
- <iOS> The operation could not be performed because of one or more tree conflicts.
- Determine whether the product of a and b is even or odd.
- ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.al
- "Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.".
- Linux and C[2]: What is the function of inet_aton or inet ntoa ?
- Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. (转)