Hence, (A) is correct.

The Gateway to Computer Science Excellence

+2 votes

2,5,1,7,9,12,11,10

this is our array after 1st partitioning in quick sort.

before solving it you should know that---->

1) Quick sort is an algorithm that uses** divide and conquer ** approach.

2) in this we choose an **element** as** pivot , **pivot in general is a point of balance , so by referring an element by **pivot **in quick sort means that it will be at his place after first **pass** or after a **partition. (**usually we take last element in array or list as **pivot)**

3) after partition the element we have chosen as pivot will be at it's correct position **in such a way that elements to it's left will be smaller than it and elements to its right will be larger than it.**

**eg----> **let array be 5,4,1,2,3 let pivot be **3 ** then after first partition array would look like this

1,2,**3**,5,4 and you may see 3 reached at its correct position and elements left to it 1,2 are smaller and elements right to it are larger.

now in our question

we are given array after 1st partition

2,5,1,7,9,12,11,10 so we know nothing about its previous arrangement so we dont know that which no. was chosen as pivot

but from 2) we know pivot will be at its correct place. so according to array we can see that 7 & 9 are at their correct place

( in sorted form----->1,2,5, **7** , **9 **,10,11,12 if we compare it with above sequence then we see 7& 9 are at correct place)

but this is not over check using 3) that left of pivot is always small and right is pivot is always larger

so checking element** 7 **we** **see left of it is smaller and right of it is larger so it seems it can be pivot

now check ** 9 **we** **see left of it is smaller and right of it is larger so it also seems it can be pivot

but it is not possible to take 2 elements as pivot at same time

so either 7 can be pivot or 9 can be pivot.

so correct answer is a) either 7 or 9 can be pivot

- All categories
- General Aptitude 1.9k
- Engineering Mathematics 7.5k
- Digital Logic 2.9k
- Programming and DS 4.9k
- Algorithms 4.3k
- Theory of Computation 6.2k
- Compiler Design 2.1k
- Databases 4.1k
- CO and Architecture 3.4k
- Computer Networks 4.1k
- Non GATE 1.5k
- Others 1.5k
- Admissions 595
- Exam Queries 576
- Tier 1 Placement Questions 23
- Job Queries 72
- Projects 17

50,647 questions

56,492 answers

195,439 comments

100,704 users