21 Sorting Part 1

21 Sorting Part 1 - Sorting and order statistics, part 1...

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

View Full Document Right Arrow Icon
Sorting and order statistics, part 1 15-211: Fundamental Data Structures and Algorithms Charlie Garrod 06 April 2010
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 Alpha-beta search ( α - β search) α : the best score player 1 (max) can guarantee based on the nodes explored so far β : the best score player 2 (min) can guarantee based on the nodes explored so far -1 99 8 P2(min) P1(max) 42 P1(max) ( α , β )= ( - , ) 84 61 ( - , ) (42, ) (42, ) (42, ) (42,-1)
Background image of page 2
3 Bounded-depth search Only search part way down the tree For non-terminal nodes, estimate the value of the position ……………………………………… e.g., depth 3:
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 Today: Sorting Definitions and “bad” sorting algorithms Better sorting algorithms Remember MergeSort… HeapSort… QuickSort…
Background image of page 4
5 Definition of sorting A sequence a 1 , a 2 ,… a n is sorted (in non- decreasing order) if a i a i+1 for all i < n e.g. -12, 8, 8, 13, 19, 42 is sorted -12, 13, 8, 19, 8, 42 is not sorted “austria”, “brazil”, “britain” is sorted
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 Correctness of a sorting algorithm Must terminate Output should be sorted Output should contain same items (and duplicates) as input sequence
Background image of page 6
7 Characterizing unsorted sequences If a sequence isn’t sorted, how “not sorted” is it? -12, 1, 3, 8, 13, 19, 23, 49, 38, 42 seems nearly sorted 49, 23, 1, 42, 13, -12, 38, 3, 19, 8 seems far from sorted
Background image of page 7

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

View Full DocumentRight Arrow Icon
8 Characterizing unsorted sequences boolean: 0/1 yes/no it’s (not) sorted # of items in an incorrect place # of inversions Sum of distances between each item and its correct place
Background image of page 8
9 Desirable sorting properties In-place Doesn’t require much extra memory Adaptive Faster if the input is nearly sorted Stable Doesn’t permute duplicate items
Background image of page 9

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

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 05/10/2011.

Page1 / 36

21 Sorting Part 1 - Sorting and order statistics, part 1...

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

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