{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

Hashing Biostatistics 615 / 815 ecture 9 Lecture 9

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

View Full Document
Scheduling z Lectures on Hashing: eview session: z Review session: October 14, 2008 z Mid-term (in class): ctober 16 2008 October 16, 2008
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

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

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

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

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

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

View Full Document
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.
Idea z If all items are integers within a short range… … speed up search operations … avoid having to sort data z How?

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

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

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

View Full Document
z Place data into an array
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online