Lecture24 - C om p a re M a p i m p le me n t at i o n s...

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

View Full Document Right Arrow Icon
Admin Today’s topics Hashing Reading Ch 11 Terman café today after class Last chance! Lecture #24 Compare Map implementations Vector Sorted Vector BST getValue O(N) O(logN) O(logN) add O(N) O(N) O(logN) Space used, code complexity? Vector is just key+value, no overhead Fairly simple to implement (hardest part is binary search) BST adds 8 bytes of pointers to each entry Pointers, dynamic memory, recursion Plus code/space for tree-balancing to guarantee O(logN) A completely different tactic How do you look up word in dictionary? Linear search? Binary search? A-Z tabs…? Hashtable idea Table maintains B different "buckets" Buckets are numbered 0 to B -1 Hash function maps a key to value in range 0 to B-1 add/getValue hash key to determine which bucket it belongs in only search/modify this one bucket Hash functions Hash function maps key to a number Result constrained to some range Result is stable Same key in -> same number out
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/12/2011 for the course CS 108 taught by Professor Smith during the Spring '11 term at Central Mich..

Page1 / 3

Lecture24 - C om p a re M a p i m p le me n t at i o n s...

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

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