{19,83,82,75,57,18,17,60,84,1,31,32,43,14,36,8,2,11,22,26} 1. In the ShellSort,
ID: 3848891 • Letter: #
Question
{19,83,82,75,57,18,17,60,84,1,31,32,43,14,36,8,2,11,22,26}
1. In the ShellSort, what is the first gap size?
2. in the ShellSort, what will be the first 2 elements compared?
3. In the ShellSort, what is the 2nd gap size?
4. In the QuickSort, what will be the pivot element value the first time?
5. In the QuickSort, where will be pivot element be put before "partitioning" is done?
6. In the QuickSort, where will the pivot element end up AFTER "partitioning" (may help to figure out which elements will be "in the left partition")
Explanation / Answer
1.) First gap size will be n/2=20/2= 10
2) First two elements that will be compared will be array[0] and array[10] that is 19 and 31
3) 2nd gap size will be n/4=20/4=5
4) For the first time pivot element value will be array[19] that is 26
5) Before partitioning the pivot value will be put at its current location only
6) After partitioning the pivot value will end up at a position where all the elements to the left pivot will be smaller than pivot and the values to the right of pivot will be greater than pivot
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.