46 votes 46 votes Let $P$ be quicksort program to sort numbers in ascending order using the first element as the pivot. Let $t_1$ and $t_2$ be the number of comparisons made by P for the inputs $[1 \ 2 \ 3 \ 4 \ 5]$ and $[4 \ 1 \ 5 \ 3 \ 2]$ respectively. Which one of the following holds? $t_1 = 5$ $t_1 < t_2$ $t_1>t_2$ $t_1 = t_2$ Algorithms gatecse-2014-set1 algorithms sorting easy + – go_editor asked Sep 26, 2014 • edited Nov 14, 2017 by kenzou go_editor 19.3k views answer comment Share Follow See all 8 Comments See all 8 8 Comments reply Show 5 previous comments Pranavpurkar commented Jan 18, 2022 reply Follow Share so both the methods are correct right? 0 votes 0 votes Kiyoshi commented Jan 19, 2022 reply Follow Share yup 0 votes 0 votes Ray Tomlinson commented Jan 13 reply Follow Share 12345 sequence requires total 10 comparisions 41532 sequence requires only 6 comparisions 0 votes 0 votes Please log in or register to add a comment.
–3 votes –3 votes both arrays are worst case example of Quick sort .∴ t1=t2. Laxmi answered Jan 27, 2015 Laxmi comment Share Follow See 1 comment See all 1 1 comment reply Sandeep Suri commented Jan 9, 2018 reply Follow Share Array 2 is not worst case example. 0 votes 0 votes Please log in or register to add a comment.
–5 votes –5 votes i think equal number of comparisons are required as the pivot element is always the highest or lwest element in the current array being worked on Bhagirathi answered Sep 26, 2014 Bhagirathi comment Share Follow See 1 comment See all 1 1 comment reply rohith1001 commented Dec 13, 2019 reply Follow Share [4 1 5 3 2] is not completely skewed. 4 / \ 1 5 \ 3 / 2 0 votes 0 votes Please log in or register to add a comment.