kannan s
BAN USER
Comments (7)
Reputation 20
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.
Comment hidden because of low score. Click to expand.
0
of 0 vote
I understand the question in a different way. There are stream of n integers and u r asked to print first 100 large numbers.
Use quick sort to get the 100 the number say x from the array O(n) and display the numbers which are <=x.O(n)
max = ans(a[],lower,upper,n) O(n)
print(all nos <= max in array) O(n)
ans(a[],lower,upper,n)
{
while(upper>= lower)
{
int i= spilt(a[],lower,upper,n); split function is Quick sort operation
if(i==n)
return a[i];
if(i<n)
{
upper=i+1;
n=n-i;
}
if(i>n)
{
lower=i+1;
n=n-i;
}
}
}
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.
small correction in m ysolution..
- kannan s January 25, 2013consider q3 as stack -
q1 and q2 as queue.