Bin
BAN USER
Comments (6)
Reputation 10
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
1. go through the first tree and find all leaves, store them
2. go through the second tree and compare each leaf with pre-stored leaves
space O(n), time O(n^2)
or we can do it in o(n) if each node has parent pointer. one leaf can only pointer to one parent which ether in tree1 or tree2. so we can iterate two tree by storing parent(pptr) and current node pointer(nptr), check pptr with nptr->parent if nptr is leaf.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
who can write the algorithm for 1D array, and mark which letter has been used to compose a word? Use as many letters as you can?
- Bin March 08, 2013