1 / 11

Analysis of Algorithms CS 477/677

This lecture discusses the mid-term results for CS 477/677, including interval trees and their operations, properties of intervals, designing interval trees, and interval search.

hutchinsonj
Download Presentation

Analysis of Algorithms CS 477/677

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. Analysis of AlgorithmsCS 477/677 Instructor: Monica Nicolescu Lecture 15

  2. Mid-Term Results CS 477 min = 33 max = 110 average = 76.3 CS 477/677 - Lecture 15

  3. Mid-Term Results CS 677 min = 70 max = 119 average = 96 CS 477/677 - Lecture 15

  4. Interval Trees Def.:Interval tree = a red-black tree that maintains a dynamic set of elements, each element x having associated an interval int[x]. • Operations on interval trees: • INTERVAL-INSERT(T, x) • INTERVAL-DELETE(T, x) • INTERVAL-SEARCH(T, i) CS 477/677 - Lecture 15

  5. i i i i j j j j i j j i Interval Properties • Intervals i and j overlap iff: low[i] ≤ high[j] and low[j] ≤ high[i] • Intervals i and j do not overlap iff: high[i] < low[j] or high[j] < low[i] CS 477/677 - Lecture 15

  6. Interval Trichotomy • Any two intervals i and j satisfy the interval trichotomy: exactly one of the following three properties holds: • i and j overlap, • i is to the left of j (high[i] < low[j]) • i is to the right of j (high[j] < low[i]) CS 477/677 - Lecture 15

  7. high[int[x]] max max[left[x]] max[right[x]] Designing Interval Trees • Underlying data structure • Red-black trees • Each node x contains: an interval int[x], and the key: low[int[x]] • An inorder tree walk will list intervals sorted by their low endpoint • Additional information • max[x] = maximum endpoint value in subtree rooted at x • Maintaining the information max[x] = Constant work at each node, so still O(lgn) time CS 477/677 - Lecture 15

  8. [16, 21] 30 [25, 30] 30 [26, 26] 26 [17, 19] 20 [19, 20] 20 [8, 9] 23 [15, 23] 23 [5, 8] 10 [6, 10] 10 [0, 3] 3 Designing Interval Trees • Develop new operations • INTERVAL-SEARCH(T, i): • Returns a pointer to an element x in the interval tree T, such that int[x] overlaps with i, or NIL otherwise • Idea: • Check if int[x] overlaps with i • Max[left[x]]≥ low[i] • Go left • Otherwise, go right low high [22, 25] CS 477/677 - Lecture 15

  9. [5, 8] 10 [0, 3] 3 [15, 23] 23 [8, 9] 23 [19, 20] 20 [6, 10] 10 [26, 26] 26 [25, 30] 30 [16, 21] 30 [17, 19] 20 x = NIL Example x i = [11, 14] i = [22, 25] x x CS 477/677 - Lecture 15

  10. INTERVAL-SEARCH(T, i) • x ← root[T] • while x ≠ nil[T] and i does not overlap int[x] • do if left[x] ≠ nil[T] and max[left[x]] ≥ low[i] • then x ← left[x] • else x ← right[x] • return x CS 477/677 - Lecture 15

  11. Readings • Chapters 14, 15 CS 477/677 - Lecture 15

More Related