Question: 1. Sort the sequence 3 , 1 , 4 , 1 , 5 , 9 , 2 , 6 , 5 using Bubble Sort. You
1. Sort the sequence 3, 1, 4, 1, 5, 9, 2, 6, 5 using Bubble Sort. You must display the contents of the list after each pass through the list.
2. Sort 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5 using Quick Sort with median-of-three partitioning and a cutoff of 3. For each step, state the pivot and the contents of the array after swapping elements >> can you please set pivot to the last element?
the second question, the median is 5 but I found a lot of soulutions that set 5 as pivot and insert it at the middle like : 3 1 4 1 5 5 2 6 5 6 9
I want to set the pivot at the last like: 3 1 4 1 5 9 2 6 5 3 5 because my professor prefer that way
The first one i tried but i know its definitedly wrong..
I got
Pass1
1 3 4 1 5 9 2 6 5
1 3 4 1 5 9 2 6 5
1 3 1 4 5 9 2 6 5
1 3 1 4 5 9 2 6 5
1 3 1 4 5 9 2 6 5
1 3 1 4 5 2 9 6 5
1 3 1 4 5 2 6 9 5
1 3 1 4 5 2 6 5 9
Pass2
1 3 1 4 5 2 6 5 9
1 1 3 4 5 2 6 5 9
1 1 3 4 5 2 6 5 9
1 1 3 4 5 2 6 5 9
1 1 3 4 2 5 6 5 9
1 1 3 4 2 5 6 5 9
1 1 3 4 2 5 5 6 9
1 1 3 4 2 5 5 6 9
Pass 3
1 1 3 4 2 5 5 6 9
1 1 3 4 2 5 5 6 9
1 1 3 4 2 5 5 6 9
1 1 3 2 4 5 5 6 9
Pass4
1 1 3 2 4 5 5 6 9
1 1 2 3 4 5 5 6 9
and i think it looks wrong
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
