0 0 votes In quick sorting algorithm 2 elements i and j are compared if and only if among all the elements, the element to be picked as pivot is either i or j. Is this statement true or false? Algorithms algorithms quick-sort true-false + – dharmik_3103 676 views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
1 1 vote This is true statement as once the partitions are done there is no comparison in joining. But when the pivot is choosen it is compared with whole array Niraj_Kumar answered Dec 5, 2024 Niraj_Kumar comment Share Follow See 1 comment 1 1 comment reply dharmik_3103 commented Dec 5, 2024 reply Follow flag But what the quick sort algorithm says is : Consider 1st element of array as Pivot element and than maintain 2 pointers i and j which points to 2nd and last element of the array respectively and we compare both of them and if i<j and array[i]>array[j] then swap both element. So here we are comparing 2 elements (i & j) from which no one is a pivot element then our statement should be false. Am i correct ? 1 1 replyShare Please log in or register to add a comment.