In: Computer Science
use quick sort to sort the following array. show each pass and what the pivot is during the pass. please explain why you are swapping positions. do not use a compiler.
30 5 40 11 20 9 15 2 60 25 80 3 73 35 4 75 20 6
[30 5 40 11 20 9 15 2 60 25 80 3 73 35 4 75 20 6]
pivot = 6
after partition->
[5 2 3 4] 6 [9 15 30 60 25 80 40 73 35 11 75 20 20]
[5 2 3 4]->
pivot = 4
after partition->
[2 3] 4 [5]
after rcursive call on [2 3]
[2][3]
[9 15 30 60 25 80 40 73 35 11 75 20 20]->
pivot = 20
after partition->
[9 15 11] 20 [30 80 40 73 35 25 75 20]
[9 15 11]->
pivot = 11
[9] 11 [15]
[30 80 40 73 35 25 75 20]->
pivot = 20
after partition->
20 [80 40 73 35 25 75 30]
[80 40 73 35 25 75 30]->
pivot = 30
after partition->
[25] 30 [73 35 80 75 40]
[73 35 80 75 40]->
pivot = 40
after partition->
35 40 [80 75 73]
[80 75 73]->
pivot = 73
73 [75 80]
[75 80] ->
pivot = 80
[75] 80