0% found this document useful (0 votes)
28 views2 pages

Worksheet AB26.2 - QuickSort2

The document contains two examples of quicksort sorting lists. The first example sorts a list of numbers, determining that the midIndex is 5 and dividingValue is 33. It shows the list after each swap until the first recursive call. The second example sorts a list of words, determining the midIndex is 5 and dividingValue is "until". It also shows the list after each swap until the first recursive call.

Uploaded by

Mycin Bax
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views2 pages

Worksheet AB26.2 - QuickSort2

The document contains two examples of quicksort sorting lists. The first example sorts a list of numbers, determining that the midIndex is 5 and dividingValue is 33. It shows the list after each swap until the first recursive call. The second example sorts a list of words, determining the midIndex is 5 and dividingValue is "until". It also shows the list after each swap until the first recursive call.

Uploaded by

Mycin Bax
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Java Curriculum for AP Computer Science, Worksheet AB26.

2 1

Worksheet AB26.2

QuickSort2

1. Practice sorting the following data using quickSort. First, determine the values for
midIndex and dividingValue assuming that the first item is at index zero. Then, write the
correct sequence of integers in the list after each swap has been made - until the code
makes its first recursive call.

28 42 69 8 100 33 36 3 84 21 40 5

midIndex = ​5 dividingValue = ​33

Sequence of integers in the list after a swap has been made:

[28, 5, 69, 8, 100, 33, 36, 3, 84, 21, 40, 42]

[28, 5, 21, 8, 100, 33, 36, 3, 84, 69, 40, 42]

[28, 5, 21, 8, 3, 33, 36, 100, 84, 69, 40, 42]

[3, 5, 21, 8, 28, 33, 36, 100, 84, 69, 40, 42]

[3, 5, 8, 21, 28, 33, 36, 100, 84, 69, 40, 42]

[3, 5, 8, 21, 28, 33, 36, 42, 84, 69, 40, 100]

[3, 5, 8, 21, 28, 33, 36, 42, 40, 69, 84, 100]

[3, 5, 8, 21, 28, 33, 36, 40, 42, 69, 84, 100]

2. After determining the values for midIndex and dividingValue assuming that the first item
is at index zero, write the correct sequence of words in the list after each swap has been
made - until the code makes its first recursive call (as you did in #1 above with integers).

sort these words using quicksort until a recursive call is made

midIndex = ​5 dividingValue = ​until

Sequence of words in the list after a swap has been made:

[sort, these, made, using, quicksort, until, a, recursive, call, is, words]

[sort, these, made, is, quicksort, until, a, recursive, call, using, words]
Java Curriculum for AP Computer Science, Worksheet AB26.2 2

[sort, these, made, is, quicksort, call, a, recursive, until, using, words]

[a, these, made, is, quicksort, call, sort, recursive, until, using, words]

[a, call, made, is, quicksort, these, sort, recursive, until, using, words]

[a, call, is, made, quicksort, these, sort, recursive, until, using, words]

[a, call, is, made, quicksort, recursive, sort, these, until, using, words]

You might also like