zxyecn
BAN USER
Comments (4)
Reputation -5
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.
Comment hidden because of low score. Click to expand.
0
of 0 vote
In the solution above, to find the max and min, the program has to compare 2n times. as we know, the lower bound of select max and min is (3/2)n-2. So we can reduce the compare times to (3/2)n requiring one more space.
min = queue.head.val
max = queue.head.val
prior.
queue.head = queue.head.next
for node in queue
prior = node.val;
node = node.next;
if(prior>node.val)
{
max=prior?max:prior>max;
....
}
else
{
....
}
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
quick sort.
- zxyecn March 11, 2012