+1 vote
in Data Structures & Algorithms II by (110k points)
Apply Quick sort on a given sequence 7 11 14 6 9 4 3 12. What is the sequence after first phase, pivot is first element?

(a) 6 4 3 7 11 9 14 12

(b) 6 3 4 7 9 14 11 12

(c) 7 6 14 11 9 4 3 12

(d) 7 6 4 3 9 14 11 12

This question was addressed to me in semester exam.

The above asked question is from Quicksort topic in chapter Sorting of Data Structures & Algorithms II

1 Answer

+1 vote
by (614k points)
selected by
 
Best answer
The correct answer is (b) 6 3 4 7 9 14 11 12

To explain: Let’s apply Quick sort on the given sequence,

For first phase, pivot = 7

 7          11     14     6     9     4     3     12   

           i                                                          j

 7     11     14     6     9     4     3     12   

          i                                       j

 7     3     14     6     9     4     11     12   

                 i                     j

 7     3     4     6     9     14     11     12   

                      i      j

 7     3     4     6     9     14     11     12   

                      j      i

 6      3      4      7      9      14      11      12

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.

Categories

...