CS673-2015F-05
Non-Comparison Sorting
1
05-0: Counting Sort
Sorting a list of n integers
We know all integers are in the range 0 . . . m
We can potentially sort the integers faster than n lg n
Keep track of a Counter Array C:
C[i] = # of times value
CS673-2015F-08
Extending Data Structures
1
08-0: Dynamic Order Statistics
Data structure with following operations:
Insert / Remove / Find (lg n)
Find nth smallest element
Find the rank of any element (is it smallest, second smallest, etc)
How can we
CS673-2015F-07
Red/Black Trees
1
07-0: Binary Search Trees
Binary Trees
For each node n, (value stored at node n) > (value stored in left subtree)
For each node n, (value stored at node n) < (value stored in right subtree)
07-1: Example Binary Search T
CS673-2015F-04
Sorting I
04-0: Divide & Conquer
Divide a problem into 2 or more smaller subproblems
Recursively solve each subproblem
Combine the solutions of the subproblems
04-1: Divide & Conquer
Mergesort:
Divide the list in half
Recursively sort
CS673-2015F-06
Selection Probelm
1
06-0: Finding Max & Min
What is the smallest exact number of comparisons required to nd the maximum element of a list with n
elements?
What is the smallest exact number of comparisons required to nd the minimum element
CS673-2015F-03
Heaps
1
03-0: Heap Denition
Complete Binary Tree
Heap Property
Max Heap:
For every subtree in a tree, each value in the subtree is = value stored at the root of the subtree
Min Heap:
For every subtree in a tree, each value in the subt
CS673-20015F-02
Probabilistic Analysis
02-0: Hiring Problem
Need an ofce assistant
Employment Agency sends one candidate every day
Interview that person, either hire that person (and re the old one), or keep old person
Always want the best person alwa
CS673-2015F-01
Algorithm Analysis
1
01-0: Syllabus
Ofce Hours
Course Text
Prerequisites
Test Dates & Testing Policies
Try to combine tests
Grading Policies
01-1: How to Succeed
Come to class. Pay attention. Ask questions.
A question as vague as I
Department of Computer Science
University of San Francisco
Computer Science 673
Fall 2015
Homework 1: , O,
Due Friday, September 4th
All problem / exercise numbers are from the 3nd edition of Introduction to Algorithms
(the 1st and 2nd editions are diere
Department of Computer Science
University of San Francisco
Computer Science 673
Fall 2015
Homework 5: Recurrence Relations and Probability
Due Friday, September 11
All problem / exercise numbers are from the 3rd edition of Introduction to Algorithms
(the
Department of Computer Science
University of San Francisco
Computer Science 673
Fall 2015
Homework 3: Sorting
Due Monday, September 21st
All problem / exercise numbers are from the 3rd edition of Introduction to Algorithms
(the 1st and 2nd editions are di
/*
* From the book : Java 1.4 Game programming. Represents an Alien, a subclass of
* Creature. Overrides speak() method to say: Alien from planet
* <nameOfPlanet> says <getGreeting()> ! Has a fight() method that is not in the
* superclass.
*/
public class