转一些我blog上一些常见的二叉树面试问题和总结# JobHunting - 待字闺中
i*e
1 楼
二叉树是面试里常见的问题种类,大家在面试前必须熟悉这一类的问题。以下是我收集的一些常见二叉树面试问题(包括我亲身经历的)。多做多练习,相信你一定可以掌握好。
Determine if a Binary Tree is a Binary Search Tree
这题很常见,microsoft,amazon, google的面试都有人被问过。这题也是二叉树的好题
,必须得对BST的定义搞清楚。有一个常见的陷阱,就是把current node的value和left
node, right node比较;这是不正确的解法。也有一个很容易想到的brute force解法
,但是每个node会被遍历很多次。正确的优解是 (O(N)解,N=number of nodes)有两
种,面试者必须对这题熟悉。
Binary Search Tree In-Order Traversal Iterative Solution
这题应该是 google 电面经常问的问题吧。我那时候就是google电面没答好这问题,所
以就fail了,超级后悔啊。强烈推荐的问题。In-Order traversal能很轻松地用递
Determine if a Binary Tree is a Binary Search Tree
这题很常见,microsoft,amazon, google的面试都有人被问过。这题也是二叉树的好题
,必须得对BST的定义搞清楚。有一个常见的陷阱,就是把current node的value和left
node, right node比较;这是不正确的解法。也有一个很容易想到的brute force解法
,但是每个node会被遍历很多次。正确的优解是 (O(N)解,N=number of nodes)有两
种,面试者必须对这题熟悉。
Binary Search Tree In-Order Traversal Iterative Solution
这题应该是 google 电面经常问的问题吧。我那时候就是google电面没答好这问题,所
以就fail了,超级后悔啊。强烈推荐的问题。In-Order traversal能很轻松地用递