(Not logged on) | Register | Log On

You can subscribe to this discussion group using an RSS feed reader. techInterview Discussion

Answers to technical interview questions. A part of TechInterview.org

A part of techInterview.org: answers to technical interview questions.

Your host: Michael Pryor

MS: Some interesting question For soring.

I was interview for a Test lead. There were 6 round in total and all the rounds were as expected and question which were asked were as expected, like given a scenario how would you test.
This algo question I was not able t crack so, posting it.
There is an array (with +ve integer) we need to sort the array ONLY with the help of the following function.
Flip(Array a, int size, int flipPos)
so if the array is
a = 3,2,6,8,1,9
and i call
Flip(a, 6, 3)
then a = 6,2,3,8,1,9.
Any ideas in how to proceed.
He told me that you can find the largest or smallest element on o(n) time and then go ahead wth that.
Thanks.
someguy
Thursday, July 01, 2010
 
 
d Send private email
Thursday, July 01, 2010
 
 
My attempt was O(n^2) (insertion sort).

so one doubt please : we are discussing linear time sorting approach, but assuming that we are "able to find the maximum of a range of consecutive numbers in constant time."

So, doesn't "consecutive numbers" simplifies the OPs problem.
And if the input is not a set of consecutive numbers then can the above assumption be ever met.

I went through the link, but could not understand how real applications would implement such an approach.
puneet Send private email
Saturday, July 03, 2010
 
 
They wouldn't. The idea is to test how well applicants deal with a dumb interface.
d Send private email
Saturday, July 03, 2010
 
 
finding the largest no.
for(i=0;i<n;i++)
{
 if( A[1] < A[i])
 {
  flip(A,6,i);
 }
}

assuming tht flip(A,n,i) swaps elements A[1] and A[i] for an array of given size n.
Rishabbh A Dua
Tuesday, July 06, 2010
 
 
This is quite funny for a MS interview question, as it uses the algorithm from the only paper Bill Gates ever published to solve it.
lgw
Tuesday, July 20, 2010
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz