Professional Documents
Culture Documents
Priority Queues: 1. Find K Numbers With Most Occurrences in The Given Array
Priority Queues: 1. Find K Numbers With Most Occurrences in The Given Array
Priority Queues: 1. Find K Numbers With Most Occurrences in The Given Array
Example:
BST
Given two BSTs, merge them and return the pointer to the new head of the BST. Try
to do them with limited space and time complexities.
2. BST Sum tree
Given a BST, transform it into greater sum tree where each node contains sum of all
nodes greater than that node.
Given two arrays which represent a sequence of keys. Imagine we make a Binary
Search Tree (BST) from each array. We need to tell whether two BSTs will be
identical or not without actually constructing the tree.
2
/ \
1 4
/
3
2
/ \
1 4
/
3
Given a Binary Tree, print left view of it. Left view of a Binary Tree is set of nodes
visible when tree is visited from left side. Left view of following tree is 12, 10, 25.
12
/ \
10 30
/ \
25 40
Given a BST replace left node data with the sum of the nodes in the right of its
parent, and right node data with sum of the nodes in the left of the parent.
Example:
6
/ \
4 8
/ \ /\
3 5 7 9
6
/ \
24 12
/ \ / \
5 3 9 7