{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Eric-Mon

# Eric-Mon - CSE 3101 Introduction to the Design and Analysis...

This preview shows pages 1–7. Sign up to view the full content.

1 02/14/12 CSE 3101 1 Suprakash Datta datta[at]cse.yorku.ca CSE 3101: Introduction to the Design and  Analysis of Algorithms

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 1. Sorting algorithms 2. Lower bounds on sorting 3. Chapters 6-8 in [CLRS] Outline
3 Sorting First: Heapsort Heap data structure and priority queue ADT Quicksort a popular algorithm, very fast on average

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
4 Why Sorting? “When in doubt, sort” – one of the principles of algorithm design. Sorting used as a subroutine in many of the algorithms: Searching in databases: we can do binary search on sorted data A large number of computer graphics and computational geometry problems Closest pair, element uniqueness A large number of sorting algorithms are developed representing different algorithm design techniques. A lower bound for sorting (n log n) is used to prove lower bounds of other problems.
5 Sorting algorithms so far Insertion sort, selection sort Worst-case running time Θ (n 2 ) ; in-place Merge sort Worst-case running time (n log n) , but requires additional memory (n) ; (WHY?)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
6 Selection sort A takes Θ (n) and B takes (1) : (n 2 ) in total Idea for improvement: use a data structure , to do both A and B in O(lg n) time, balancing the work, achieving a better trade-off, and a total running time O(n log n) . Selection-Sort (A[1. .n]): For i n downto 2 A : Find the largest element among A[1. .i] B : Exchange it with A[i] Selection-Sort (A[1. .n]): For i n downto 2 A : Find the largest element among A[1. .i] B : Exchange it with A[i]
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 27

Eric-Mon - CSE 3101 Introduction to the Design and Analysis...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online