Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. -11, 2, 10, 8, 0
- -11, 2, 10, 8, 0
- -11, 2, 8, 10, 0
- -11, 0, 2, 8, 10
- 2. -11, 2
- -11, 2, 10
- -11, 0, 2, 8, 10
- 3. 2, 8
- 0, 2, 8
- -11, 0, 2, 8
- -11, 0, 2, 8, 10
- 4.
- a. Insertion sort: O(n2)
- b. Merge sort: O(n log(n))
- c. Quicksort: O(n log(n))
- 5.
- a. Insertion sort: O(n)
- b. Merge sort: O(n log(n))
- c. Quicksort: O(n log(n))
- 6.
- a. Insertion sort: O(n2)
- b. Merge sort: O(n log(n))
- c. Quicksort: O(n log (n))
- 7.
- a. Insertion sort is stable because elements are sorted from front to back
- b. Merge sort is stable because the duplicate elements will be added to the temporary and final arrays in order from right to left
- c. Quicksort is unstable, because the elements are rearranged depending on the midpoint chosen in each step
- 8. No, because if the pivot was the lowest value in the function then j would never stop decreasing
Advertisement
Add Comment
Please, Sign In to add comment