7 votes 7 votes Which of the following is/are the possible array contents after second pass of Quick Sort for the following initial ordering assuming first element is taken as pivot?$$34, 8, 64, 51, 32, 21$$ $8, 21, 32, 34, 51, 64$ $8, 32, 34, 51, 64, 21$ $8, 34, 51, 64, 32, 21$ $8, 34, 64, 51, 32, 21$ Algorithms go2025-algorithms-1 quick-sort + – gatecse asked Aug 18, 2020 gatecse 324 views answer comment Share Follow See 1 comment See all 1 1 comment reply Aditya kanwar commented Oct 20, 2021 reply Follow Share sir can you please show it stepwise 0 votes 0 votes Please log in or register to add a comment.
2 votes 2 votes In first pass $34$ is the pivot. So, it'll get position as in the final sorted order which is $4^{th}$ position. This is true only for option A. gatecse answered Aug 18, 2020 gatecse comment Share Follow See all 4 Comments See all 4 4 Comments reply val_pro20 commented Dec 4, 2020 reply Follow Share can you show the stepes after 2 nd pass 0 votes 0 votes prajjwalsingh_11 commented Dec 21, 2020 reply Follow Share Can anyone please show all the steps till the end 1 votes 1 votes faisal_sayyed commented Nov 23, 2021 reply Follow Share Since 34 is the pivot element, all the elements to the left must be less than 34, and all the elements to the right of it must be greater than 34. Here this condition is satisfied by option A only. So Option A is the correct option. For more you can refer to this video 0 votes 0 votes varund137 commented Nov 14, 2023 reply Follow Share @gatecse Can you please show it stepwise and clear the confusion whether full procedure of quicksort was required to be implemented or only till second pass as asked……..?? 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes So basically in first pass (or swap) 21 and 64 get swapped and in 2nd Swap when the Right Bound crosses Left Bound, 34 gets placed before 51. Giving us 8,21,32,34,51,64 nachi78 answered Jan 31 nachi78 comment Share Follow See all 0 reply Please log in or register to add a comment.