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