摘要:
You have two very large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of ... 阅读全文
摘要:
Design an algorithm and write code to find the first common ancestory of two nodes in a binary tree. Avoid storing additional nodes in data structure.... 阅读全文
摘要:
Implement a function to check if a binary tree is a binary search tree./* The inorder travel of a BST is strictly increasing. We track the pre node of... 阅读全文
摘要:
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 have... 阅读全文
摘要:
Given a sorted (increasing order) array with unique integer elements, write an algorithm to create a binary search tree with minimal height.There is a... 阅读全文
摘要:
Implement a function to check if a binary tree is balanced. For the purposes of this question, a balanced tree is defined to be a tree such that the h... 阅读全文
摘要:
Write a program to sort a stack in ascending order (with biggest items on top). You may use at most one additional stack to hold items, but you may no... 阅读全文
摘要:
Implement a MyQueue class which implements a queue using two stacks./*Use two stacks, when enqueue, first pop all the elements in stack2 on stack1, th... 阅读全文
摘要:
Imagine a (literal) stack of plates. If the stack gets too high, it might topple. Therefore, in real life, we would likely start a new stack when the ... 阅读全文
摘要:
How would you design a stack which, in addition to push and pop, also has a function min which returns the minimum element? Push, pop and min should a... 阅读全文