2013年1月25日

二叉树相关的数据结构和算法

摘要: 1. 二叉树(binary tree):最基本树型结构,每个结点最多有两个子节点,分别成为左子节点(left child node)和右子节点(right child node)。相关题目:a. 给定根结点,计算二叉树的最大深度。View Code //递归解法class Solution {public:int maxDepth(TreeNode* root){ if (root == NULL) return 0; if (root->left == NULL && root->right == NULL) return 1; if (root->left 阅读全文

posted @ 2013-01-25 01:25 梁霄 阅读(302) 评论(0) 推荐(0)

导航