2 years ago
csgeek
in English ยท 1,713 Views
likes 3clips 1comments 0
Data Structures: Hash Tables
I love hash tables. Kidding, I just learned about them not too long ago in class. Love is a strong word. haha. What is a hash table? It's an associative array where you map keys to values using a hash function to find the index in the array. Fancy stuff, right? So how does a basic, direct address hash table work? Let's say you have n elements and each element has a unique key, k, that is an integer between 1 & m, where m>=n. If you have a table named T, then you would store the items as T[k] if T[k] contains an element already, you would return the element, otherwise you would return a null. This is assuming that the keys are unique and there is a bound on the range of the key. I'm still learning some more, and hoping to practice it more on my next assignment. Any hash table experts out there willing to share their wisdom?
csgeek clipped in 1 collections
0 comments