【转】IT名企面试:微软笔试题(1)
<div id="cnblogs_post_body">微软在IT界依然是数一数二的企业了,不少人的梦想都是进入微软公司。那么在这之前的面试以及笔试就需要进行一下准备了。那么这里就来看看小编为大家总结的微软笔试题吧。【转】IT名企面试:腾讯笔试题(1)
【转】IT名企面试:腾讯笔试题(2)
【转】IT名企面试:微软笔试题(1)
【转】IT名企面试:微软笔试题(2)
微软笔试题:写程序找出二叉树的深度
一个树的深度等于max(左子树深度,右子树深度)+1。可以使用递归实现。
假设节点为定义为
<div class="cnblogs_code">struct Node {Node* left;Node* right;};int GetDepth(Node* root) {if (NULL == root) {return 0;}int left_depth = GetDepth(root->left);int right_depth = GetDepth(root->right);return left_depth > right_depth ? left_depth + 1 :right_depth + 1;}
页:
[1]