Data Structure

  • hash table / hash map / hash set

  • heap / priority heap / min heap / max heap

  • Union Find

  • queue interface: LinkedList, PriorityQueue, Deque(doulbe queue)

  • Trie (inset/find/startswith)

  • Binary Indexed Tree / Fenwick Tree

Hash table / map

  • time complexity O(keyLength), not O(1), because need to calculate hash value

  • Hash function Magic Number: 31, prime number

  • Rehash size / capacity > 10%, need to rehash

collision

Open Hashing vs Closed Hashing

  • Open Hashing, LinkedList

deficiency: LinkedList slower than Array https://www.cs.usfca.edu/~galles/visualization/OpenHash.html

  • Closed Hashing, Array

deficiency: when item deleted, occupy position, affect find time. https://www.cs.usfca.edu/~galles/visualization/ClosedHash.html

LRU: HashMap + DoublyLinkedList

http://www.jiuzhang.com/solutions/lru-cache/

Last updated

Was this helpful?