21 Sorting Part 1

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

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

Sorting and order statistics, part 1 15-211: Fundamental Data Structures and Algorithms Charlie Garrod 06 April 2010

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

View Full Document
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)
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:

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

View Full Document
4 Today: Sorting Definitions and “bad” sorting algorithms Better sorting algorithms Remember MergeSort… HeapSort… QuickSort…
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

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

View Full Document
6 Correctness of a sorting algorithm Must terminate Output should be sorted Output should contain same items (and duplicates) as input sequence
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

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

View Full Document
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
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

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

View Full Document
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
Ask a homework question - tutors are online