210 likes | 312 Vues
Exploring stacks, queues, priority queues, doubly linked lists, direct addressing, and hash tables. Learn key operations and implementations.
E N D
Stack top
2 4 6 8 9 top 2 4 6 8 9 x
2 4 6 8 9 top 2 4 6 8 9 x
Queue head tail 1 3 6 2 5
1 2 3 tail 1 2 3 x
x 1 2 3 head 1 2 3
Priority Queue • A priority queue is a data structure for maintaining a set of elements, each with an associated value, called a key. • A max-priority queue supports the following operations: Insert(S,x), Maximum(S), Extract-Max(S), Increase-Key(S,x,k). • Max-Heap can be used for implementing max-priority queue.
Doubly Linked List 1 2 3 prev key next
x is an object!!! 1 x 2 1
x is an object!!! x 2 3 1 2 1
Sentinel • A sentinel is a dummy object that allow us to simplify the boundary condition. • With sentinel, a doubly linked list can be turned into a circular one. • The sentinel nil[L] is placed between the head and the tail.
Direct Addressing • Direct addressing is a simple technique that work well when the universe of keys is reasonably small. • Direct-address table is an array in which each position, or slot, corresponds to a key in the universe. • If the universe is large, how to do? • Hashing!
Hash Table • Collision resolution by chaining
What we learnt in this lecture? • Review elementary data structures