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

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

View Full Document Right Arrow Icon
1 02/14/12 CSE 3101 1 Suprakash Datta datta[at]cse.yorku.ca CSE 3101: Introduction to the Design and  Analysis of Algorithms
Background image of page 1

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

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

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

View Full DocumentRight Arrow Icon
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.
Background image of page 4
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?)
Background image of page 5

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

View Full DocumentRight Arrow Icon
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]
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/13/2012 for the course CSE 3101 taught by Professor Andy during the Winter '10 term at York University.

Page1 / 27

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

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online