Priority Search Trees - Advanced Data Structures - Lecture Slides, Slides of Computer Science

These are the Lecture Slides of Advanced Data Structures which includes Split Algorithm, Unbalanced Binary Search Trees, Forward Pass, Forward Pass Example, Backward Cleanup Pass, Retrace Path, Current Nodes, Roots of Respective Tries, Branch Nodes etc. Key important points are: Priority Search Trees, Distinct Ordered Pairs, Basic Operations, Rectangle Operations, Return Element, Complexity of Enumeraterectangle, Applications Visibility, Vertical Line Segments

Typology: Slides

2012/2013

Uploaded on 03/19/2013

dharmakeerti
dharmakeerti 🇮🇳

4.2

(27)

89 documents

1 / 14

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Priority Search Trees
Keys are distinct ordered pairs (xi,yi).
Basic operations.
get(x,y) … return element whose key is (x,y).
delete(x,y) … delete and return element whose key
is (x,y).
insert(x,y,e) … insert element e, whose key is (x,y).
Rectangle operations.
minXinRectangle(xL,xR,yT)
Return element with min x-coordinate in the
rectangle defined by the lines, x= xL, x= xR, y =
0, y = yT, xL<= xR, 0 <= yT.
I.e., return element with min xsuch that
xL<= x <= xR and 0 <= y <= yT.
xLxR
yT
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download Priority Search Trees - Advanced Data Structures - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

Priority Search Trees

  • Keys are distinct ordered pairs (xi, yi).
  • Basic operations. ƒ get(x,y) … return element whose key is (x,y). ƒ delete(x,y) … delete and return element whose key is (x,y). ƒ insert(x,y,e) … insert element e, whose key is (x,y).
  • Rectangle operations.

minXinRectangle(xL,xR,yT)

  • Return element with min x-coordinate in the rectangle defined by the lines, x= xL, x= xR, y = 0 , y = yT, xL <= xR, 0 <= yT.
  • I.e., return element with min x such that xL <= x <= xR and 0 <= y <= yT.

xL xR

yT

maxXinRectangle(xL,xR,yT)

  • Return element with max x-coordinate in the rectangle defined by the lines, x= xL, x= xR, y = 0 , y = yT, xL <= xR, 0 <= yT.
  • I.e., return element with max x such that xL <= x <= xR and 0 <= y <= yT.

xL xR

yT

minYinXrange(xL,xR)

  • Return element with min y-coordinate in the rectangle defined by the lines, x= xL, x= xR, y = 0 , y = infinity, xL <= xR.
  • I.e., return element with min y such that xL <= x <= xR.

xL xR

Applications – Visibility

  • Dynamic set of semi-infinite vertical line segments. ƒ Vertical lines with end points (xi,infinity) and (xi,yi).

(2,1)

(3,4) (4,2)

(5,6)

(6,3)

Opaque/translucent lines.

Translucent Lines

  • Eye is at (x,y).
  • Priority search tree of line end points.
  • enumerateRectangle(x, infinity, y).

(2,1)

(3,4) (4,2)

(5,6)

(6,3) 0

y

x (^) infinity

Opaque Lines

  • Eye is at (x,y).
  • Priority search tree of line end points.
  • minXinRectangle(x, infinity, y).

(2,1)

(3,4) (4,2)

(5,6)

(6,3) 0

y

x (^) infinity

Bin Packing

  • First fit.
  • Best fit.
  • Combination. ƒ Some items packed using first fit. ƒ Others packed using best fit.
  • Memory allocation.

Best Fit

  • minXinRectangle(neededSize, infinity, infinity)

bin index

available capacity

neededSize

Online Intersection Of Linear Intervals

  • Intervals are of the form [i,j], i < j.
  • [i,j] may, for example represent the fact that a machine is busy from time i to time j.
  • Answer queries of the form: which intervals intersect/overlap with a given interval [u,v], u < v. ƒ List all machines that are busy at any time between u and v.

Example

  • Machine a is busy from time 1 to time 3.
  • Interval is [1,3].
  • Machines a, b, c, e, and f are busy at some time in the interval [2,4].

1 e

1 a 3

2 c 4

4 b 6

(^3) f 6 5 d 7

2

Example

  • Interval [i,j] corresponds to the pair (x,y), where x = j and y = i.

1 e

1 a 3

2 c 4

4 b 6

(^3) f 6 5 d 7

2

e a

f

b

c

d

  • enumerateRectangle(u, infinity, v).
  • enumerateRectangle(2, infinity, 4).

Interval Containment

• Interval [i,j] corresponds to the pair (x,y),

where x = j and y = i.

1 e

1 a 3

2 c 4

4 b 6

(^3) f 6 5 d 7

2

e a

f

b

c

d

• enumerateRectangle(v, infinity, u).

• enumerateRectangle(6, infinity, 5).

Intersecting Rectangle Pairs

• (A,B), (A,C), (D, G), (E,F)

  • Online interval intersection.

A

C^ F

D

E

B

G

Algorithm

  • Examine horizontal edges in sorted y order. ƒ Bottom edge => insert interval into a priority search tree. ƒ Top edge => report intersecting segments and delete the top edge’s corresponding bottom edge.

A

C^ F

D

E

B

G

Complexity

  • Examine edges in sorted order. ƒ Bottom edge => insert interval into a priority search tree. ƒ Top edge => report intersecting segments and delete the top edge’s corresponding bottom edge.
  • O(n log n) to sort edges by y, where n is # of rectangles. ƒ Insert n intervals … O(n log n). ƒ Report intersecting segments … O(n log n + s). ƒ Delete n intervals … O(n log n).

IP Router Table

  • lmp(d) = [maxStart(p(d)), minFinish(p(d))]
  • minXinRectangle(d,infinity,d) finds lmp(d) except when >1 prefixes have same finish point.

d

IP Router Table

  • Remap finish points so that all prefixes have different finish point.
  • f’ = 2wf – s + 2w^ – 1 , w = length of d
  • f’ is smaller when s is bigger

d

IP Router Table

  • Complexity is O(log n) for insert, delete, and find longest matching-prefix.

d