1 votes 1 votes After applying few passes of quick sort on a given array, the following output was obtained: 1,10,5,8,25,44,55,30,70 Then how many pivot elements are there in the above output? Algorithms algorithms quick-sort + – Sambhrant Maurya asked Aug 6, 2018 • reshown Dec 18, 2019 by Sambhrant Maurya Sambhrant Maurya 1.1k views answer comment Share Follow See all 3 Comments See all 3 3 Comments reply Gatetarget_100 commented Aug 6, 2018 i edited by Gatetarget_100 Aug 6, 2018 reply Follow Share 1 ,25 and 70 is the pivot element i guess, Pivot element means that it divide array such that. it one side contain element smaller that pivot element and other side contain element greter thn pivot element,For ex. For 1 its right hand side contain all value greater than 1 and there is no element in left hand side, Similarly for 70 it left hand side contain all element less than 70 .Correct me if i am wrong 1 votes 1 votes Prince Sindhiya commented Aug 6, 2018 reply Follow Share Answer should be 3 1,25 and 70 2 votes 2 votes smsubham commented Dec 18, 2019 reply Follow Share Duplicate https://gateoverflow.in/46249/quick-sort-partition-procedure 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes There should be 3 pivot elements. Property of output of each pass of Quicksort -> 1. The pivot elements is on its correct position. 2. All the elements on the left of pivot are smaller than it and elements on the right are greater than it. So in the given question -> 1, 25 , 70 are pivot elements hence no of pivot elements are 3. Brij gopal Dixit answered Aug 6, 2018 Brij gopal Dixit comment Share Follow See all 0 reply Please log in or register to add a comment.