l09-huffman

l09-huffman - CS112 Data Structures Lecture 9 Uses of trees...

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

CS112: Slides for Prof. Steinberg ʼ s lecture 1 Lecture 9 CS112: Data Structures CS112: Data Structures Lecture 9 Uses of trees

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

View Full Document
CS112: Slides for Prof. Steinberg ʼ s lecture 2 Lecture 9 Exam 1 results Exam 1 results Problem 2 was a large part of the problem Adding 10 points, Also making 20 extra credit percentage is out of 130 Sakai will stay the raw score
CS112: Slides for Prof. Steinberg ʼ s lecture 3 Lecture 9 Confusion Confusion “Each element of A has a 1/4 probability of being found in B.” Is NOT the same as “1/4 of the elements in A will be in B.”

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

View Full Document
CS112: Slides for Prof. Steinberg ʼ s lecture 4 Lecture 9 Example: toss two coins Example: toss two coins Toss two fair coins - a “double flip” Do it 4 times - a “trial” Probability of double flip heads-heads = 1/4 Does not mean that exactly one of the 4 double flips in a trial will always be heads- heads Does mean that the long run average number of heads-heads/trial approaches 1
CS112: Slides for Prof. Steinberg ʼ s lecture 5 Lecture 9 Worst case: no probability Worst case: no probability Probability only matters for average cost “Probability of case j is 1/n” Worst case cost: find the one case with highest cost No matter how likely or unlikely

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

View Full Document
CS112: Slides for Prof. Steinberg ʼ s lecture 6 Lecture 9 Example Example repeats, both n elements For each element in A, check if also in B One worst case, n = 4: A: 10, 10, 10, 10 B: 20, 23, 19, 10
CS112: Slides for Prof. Steinberg ʼ s lecture 7 Lecture 9 Review Review Built-in Hashing in Java Built-in Hashing in Java The class java.util.HashMap<K, V> Mapping from (unique) key to a value Note: generic with two class parameters: K: class of keys V: class of values E.g. Driver’s license ID (String) => Driver object (name, address, etc.): java.util.HashMap<String, Driver> See Driver.java and UseDriverMap.java

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

View Full Document
CS112: Slides for Prof. Steinberg ʼ s lecture 8 Lecture 9 Traversals
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 32

l09-huffman - CS112 Data Structures Lecture 9 Uses of trees...

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

View Full Document
Ask a homework question - tutors are online