1 / 21

Lecture 6 Data Structures

Lecture 6 Data Structures. 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.

leanna
Télécharger la présentation

Lecture 6 Data Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 6 Data Structures

  2. Stack top

  3. 2 4 6 8 9 top 2 4 6 8 9 x

  4. 2 4 6 8 9 top 2 4 6 8 9 x

  5. Queue head tail 1 3 6 2 5

  6. 1 2 3 tail 1 2 3 x

  7. x 1 2 3 head 1 2 3

  8. 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.

  9. Doubly Linked List 1 2 3 prev key next

  10. x is an object!!! 1 x 2 1

  11. x is an object!!! x 2 3 1 2 1

  12. 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.

  13. 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!

  14. Hash Table • Collision resolution by chaining

  15. Hash Functions

  16. What we learnt in this lecture? • Review elementary data structures

More Related