随笔分类 - Cracking the Coding Interview
摘要:Write an algorithm to find the 'next' node(i.e. in-order successor) of a given node in a binary search tree. 这道题让我们寻找给定节点的中序后继节点,最简单的方法就是中序遍历tree, 并用一
阅读全文
摘要:Implement a function to check if a binary tree is a binary search tree. 这道题很经典,让我们判断一棵树是不是二叉查找树。但是首先要确定一下二叉查找树的定义,比如leetcode 98题中的定义左<根<右就可以直接通过判断中序遍历
阅读全文
摘要:Implement a function to check if a binary tree is balanced. For the purpose of this question, a balanced tree is defined to be a tree such that the he
阅读全文
摘要:Given a binary tree, design an algorithm which creates a linked list of all the nodes at each depth.(e.g., if you have a tree with depth D, you'll hav
阅读全文
摘要:Given a sorted(increasing order) array with unique integer elements, write an algorithm to create a binary search tree with minimal height. 这道题给了我们一个从
阅读全文
摘要:Given a directed graph, design an algorithm to find out whether there is a route between nodes. 这道题让我们判断给定的一个图的任意两个节点间是否有路径。首先我们要知道如何定义一个图, 一般最常用的两种表示
阅读全文

浙公网安备 33010602011771号