615.09 - Hashing Hashing Biostatistics 615 / 815 Lecture 9...

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

View Full Document Right Arrow Icon
Hashing Biostatistics 615 / 815 ecture 9 Lecture 9
Background image of page 1

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

View Full DocumentRight Arrow Icon
Scheduling z Lectures on Hashing: eview session: z Review session: October 14, 2008 z Mid-term (in class): ctober 16 2008 October 16, 2008
Background image of page 2
Last Lecture z Merge Sort Bottom-Up Top-Down z Divide and conquer sort with guaranteed N log N running time Requires additional auxiliary storage
Background image of page 3

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

View Full DocumentRight Arrow Icon
Today z Hashing Algorithms z Fast way to organize data prior to earching searching rade savings in computing time for z Trade savings in computing time for additional memory use
Background image of page 4
Almost Trivia z Short detour… Finding primes ow do we find all prime numbers less z How do we find all prime numbers less than some number?
Background image of page 5

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

View Full DocumentRight Arrow Icon
Eratosthenes Sieve z List all numbers less than N Ignore 0 and 1 z Find the smallest number in the list Mark this number as prime Remove all its multiples from the list z Repeat previous step until list is empty
Background image of page 6
he Sieve in C The Sieve in C void list_primes () { int i, j, a [ N ]; for ( i = 2 ; i < N ; i ++) a [ i ] = 1 ; for ( i = 2 ; i < N ; i ++) if ( a [ i ]) for ( j = i * i; j < N ; j += i ) = ; a [ j ] 0; for ( i = 2 ; i < N; i ++) f ( ) rintf("%4d is prime ", i); if ( a [ i ]) printf( %4d is prime\ n, i);
Background image of page 7

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

View Full DocumentRight Arrow Icon
Notes on Prime Finding z The algorithm is extremely fast Takes <1 sec to find all primes <1,000,000 z Performance can be improved by tweaking the inner loop Can you suggest a way? lustrates useful idea: z Illustrates useful idea: Use values an indices into an array where items denote presence / absence of the value in a set.
Background image of page 8
Idea z If all items are integers within a short range… … speed up search operations … avoid having to sort data z How?
Background image of page 9

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

View Full DocumentRight Arrow Icon
Even better! z With this strategy… Adding an item to the collection takes onstant time constant time earching through the collection takes Searching through the collection takes constant time Independent of the number of objects in the collection!
Background image of page 10
Previous Search Strategies z Place data into an array O(N) z Sort array containing data O(N log N) earch for items of interest z Search for items of interest log N per search
Background image of page 11

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

View Full DocumentRight Arrow Icon
z Place data into an array
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/26/2011 for the course BIO 615 taught by Professor Abecasis during the Fall '10 term at University of Michigan.

Page1 / 38

615.09 - Hashing Hashing Biostatistics 615 / 815 Lecture 9...

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

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