Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

Consider list = { 5, 4, 2, 9, 1, 7, 3, 8, 6 } and the quick sort algorithm. Assume we always choose the first list item in the list being partitioned...

Consider list = { 5, 4, 2, 9, 1, 7, 3, 8, 6 } and the quick sort algorithm. Assume we always choose the first list item in the list being partitioned as the pivot. Trace the partition method showing how list is partitioned into listL and listR. To get you started, here is the format required for the answer

list = { 5, 4, 2, 9, 1, 7, 3, 8, 6 }, pivot = 5, leftIndex = -1, rightIndex = 9

While loop pass 1: leftIndex ends up at 0, rightIndex ends up at 6

leftIndex < rightIndex so swap list[0] and list[6]: list = { 3, 4, 2, 9, 1, 7, 5, 8, 6 }

While loop pass 2:

...

While loop pass 3:

...

While loop terminates because leftIndex = ??? >= rightIndex = ??? partition() returns ??? so listL = { ??? }, listR = { ??? }, 

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question