Skip List Skip Lists

Skip List Skip Lists

Lecture 12, Thursday 5/17/01 Skip List Skip Lists O Simple data structure, easier to implement than O Analysis: red/black trees. » Expected O(log n) lists. O Sorted linked list with “skip” pointers. » Expected total number of nodes is n+n/2+n/4+… = O(n). O Construction: » Search: find range in last list, examine this range next one down, etc. » Every element in the “bottom list” (list 0) Element passed to list 1 with probability 1/2. » Each range is expected to be constant length: » O(1) work per range, O(log n) total. » In general, element in list i is passed to list i+1 with prob. 1/2. O Works only if deletions are not malicious. 101 102 Extending Red-Black Trees Dynamic selection continued O Dynamic order statistics: O In order to be able to claim O(log n) time, » Select(x,i) - i-th smallest in tree rooted at x. need to be able to update extra fields during: » Rank(T,x) - rank of x in tree T. » Insertion/deletion into red/black tree » Rotations. O New field: Size of subtree O Easy to see that this is trivial in this case: only local O Idea: sufficient in order to know data needed. whether to go right or left. O Ex: Rank: go down, each right - add size of left subtree +1. O Example: When elements found, add 1 + left subtree. For H in the figure: size(A)+1 +size(D)+1 +1+0 =5. 103 104 Interval intersection Interval data structure O Goal: O Interval = Node » Maintain collection of intervals (support deletion/insertion) Low endpoint = key New info: max endpoint in subtree » Given an interval I, produce interval J from data structure, such that I intersects J. O Ignore open vs closed, each interval starts at a new point. O Easy to maintain during insertion/deletion/rotation 4815 18 21 23 11 17 19 7 10 16 22 105 106 1 Using the data structure Case 2 O x=root(T) O Case 2: we go left. Case 2a: overlap on left - done. while x≠ NIL & I ∩ int(x)=∅ Case 2b: no overlap on left. if left(x) ≠ NIL && max(left(x))> low(I) we went left -- left(x) != NIL, max(left(x)) >= low(i) then x = left(x) no overlap -- exists interval I’ s.t low(I’) > high(I) but tree ordered by low --- all intervals in right tree have lows else x = right(x) above high(I) ! -- no overlap there. O Theorem: if overlap exists, and search goes left, then there exists an overlap on left. Same for “goes right” I I’ O Proof: Case 1: goes right. Case 1a: overlap in right subtree - done. Case 1b: no overlap in right subtree. we went right - left(x)=NIL or max(left(x))<low(i) low(I’) In both cases there can not be overlap on the left !! 107 108 2.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    2 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us