Lecture03 - Dynamic Sets and Data Structures Basic Data...

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

View Full Document Right Arrow Icon
1 Dynamic Sets and Data Structures • Basic Data Structures and Analysis • Hash Tables • Binary Search Trees Dynamic Sets and Data Structures • Over the course of an algorithm’s execution, an algorithm may maintain a dynamic set of objects • The algorithm will perform operations on this set –Que r i e s – Modifying operations • We must choose a data structure to implement the dynamic set efficiently • The “correct” data structure to choose is based on – Which operations need to be supported – How frequently each operation will be executed Some Example Operations • Notation – S is the data structure – k is the key of the item – x is a pointer to the item • Search(S,k): returns pointer to item • Insert(S,x) • Delete(S,x): note we are given a pointer to item • Minimum or Maximum(S): returns pointer • Decrease-key(S,x) • Successor or Predecessor (S,x): returns pointer •M
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Basic Data Structures/Containers • Unsorted Arrays • Sorted Array • Unsorted linked list • Sorted linked list • Stack • Queue •H e ap Puzzles • How can I implement a queue with two stacks? – Running time of enqueue? – Dequeue? • How can I implement two stacks in one array A[1. .n] so that neither stack overflows unless the total number of elements in both stacks exceeds n? Merge Pred/Succ Max/Min Delete Insert Search Heap Sorted LL Unsorted LL Sorted Array
Background image of page 2
3 Case Study: Dictionary • Search(S,k) • Insert(S,x) • Delete(S,x) • Is any one of the data structures listed so far always the best for implementing a dictionary? • Under what conditions, if any, would each be
Background image of page 3

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

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

Page1 / 9

Lecture03 - Dynamic Sets and Data Structures Basic Data...

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

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