snyperGTR
BAN USER
Comments (5)
Reputation 15
Page:
1
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.
-1
of 1 vote
Just find the first windows minimum then compare it with the next element that is being added go th window since it is the only new element. Also since the first element is removed and if it is the smallest you will have to find the second smallest if this is the case. Shouls just be another boolean value to keep track of. Worst complexity is o( n*n) but avg is just o(1)
- snyperGTR January 30, 2013Comment hidden because of low score. Click to expand.
2
of 2 vote
I base my answer on the fact that each node can only have one parent but multiple children.
First search upward and store each parent node in a stack. Then search downward on the parent nodes.
Second search downward and store each child also in a stack. Then search downward also on these nodes. You just have to keep track on how far you are away from the given node.
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.
Why are there two time complexity for remove? Should be (log in) either way
- snyperGTR January 30, 2013