Google | Phone | Forest of Sub Trees
Anonymous User
1834

Given a binary tree and a collection of nodes to exclude, compute the collection of subtrees resulting from excluding the nodes. Restriction: the original tree should not be modified and a forest of subtrees should have copied nodes.

Example:

	  A
	/   \
   B     C*
  / \     \
 D*   E    F
/ \
G   H

Nodes to exclude: [D, C] - nodes

Result (copies of original nodes):
```
[ A', F', G', H' ]
/
B'
\
E'

  
  

public class Tree {

public class TreeNode {
char value;
TreeNode left;
TreeNode right;

}

TreeNode root;

public List excludeNodes(Set nodeToExclude ){}

}

Comments (4)