2c03-review - 00025

2c03-review - 00025 - 2, 10 2, 3, 5, 8, 9, 10 2, 3, 5, 8,...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
3 b) 6 / \ 4 7 / \ 3 9 / 1 After DELETEMIN: 6 / \ 4 7 / \ 3 9 5.[10] Here are eight integers: 8, 5, 9, 3, 2, 10. Sort them using: a.[2] insertion sort b.[5] QuickSort (choose pivot as in the textbook, not randomly) c.[3] merge sort ( non-recursive) Illustrate all the steps. Describe both worst and average case complexities. a) 8, 5, 9, 3, 2, 10 5, 8 , 9, 3, 2, 10 5, 8 , 9 , 3, 2, 10 3, 5, 8, 9,
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 2, 10 2, 3, 5, 8, 9, 10 2, 3, 5, 8, 9, 10 Worst case and average case are O(n 2 ) b) 8, 5, 9, 3, 2, 10 pivot is 10, so all elements are 10, i.e. partition results in 5, 9, 3, 2, 8 (pivot is 8) 10 empty list 5, 3, 2 (pivot is 2) 8 9 10 empty list 2 3, 5 (pivot is 5) 8 9 10 2 3 5 empty list 8 9 10 2 3 5 8 8 10 Worst case O(n 2 ), average case O(nlogn)...
View Full Document

Ask a homework question - tutors are online