Microsoft Interview Question for Testing / Quality Assurances






Comment hidden because of low score. Click to expand.
0
of 0 vote

finding smallest element:
- min = A[0]
- for i = 1 to (n-1)
if ( min > A[i] )
min = A[i]; Flip (A, n, i);
So, O(n) time to get smallest.

Once smallest is found, print it to output stream,and call Flip(A, n, n-1) which puts the last element in the array to first place, finally n-- as we removed smallest. Repeatedly we can do it to get O(n^2) sorting.

Plz correct if something seems wrong.

- Anonymous July 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

what is this Flip function doing?? to which position is this flipPos exchanging??

- xclamation July 02, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Sorry, I assumed [0,n-1] indexed array, it should be [1,n] indexed.

- Anonymous July 03, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

This is correct..

- Anonymous March 17, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

So they want you to do a bubble sort? hmm..

- Anonymous July 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void sort ( int A[] , int n )
{
    if( n < 0 )return; 
     
     int idx=0,max=INT_MIN,max_idx=-1;
     
     for( idx=0;idx<n;idx++ )
      {
          if( A[idx] < max )
           {
               max=A[idx];
               max_idx=idx;
               
               }
               
               
               }
               
        Flip( A , n ,max_idx);
        Flip( A , n , n-1 );  /* gets the largest element at end of the array */
        
        sort( A  , n-1 );
        
        }

This is bubble Sort

- Anonymous July 03, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Yes, bubble sort would solve it faster than selection sort.

- AgnelCodes July 04, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

EDIT:
I didn't read the solution above mine, bubble sort would solve it quicker than Selection sort.

- AgnelCodes July 04, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

What team asked this question?

- Anonymous July 06, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

silly question knoe!

- Anonymous July 21, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

question:

given the example array a of this question,

can we call, say, flip(A+1,2,0)?

if we can then this flip is just a swap function right?

- Anonymous March 01, 2011 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More