AUGMENTED Notes STRUCTURES DATA - Luc...
Transcript of AUGMENTED Notes STRUCTURES DATA - Luc...
AUGMENTEDDATA
STRUCTURES
(Notes
by Flava Mertens )
AUGMENTED DATA STRUCTURES
EXAMPLES :
DATA PARTICIPATING IN SEVERAL DATA STRUCTURES
SEARCH TREES t Lists
ORDER STATISTICS TREES
INTERVAL TREESLEVEL - LINKING IN RED-BLACK TREES
BINARY SPACE PARTITION TREESk -
d TREESQVADTREES
MULTIPLE DATA STRUCTURES
DATA DATASTRUCTURE I STRUCTURE 2
.#Be
Hageman)
BINARY SEARCH TREE t LIST
⑥BINARY SEARCH TREE
- -
②⑨£to£ToIHo.
.
DOUBLE LIN#¥
A CELL-
.
apparent( for BST )
re-EYE÷grnat÷ .
. . .
UPDATES after INSERT,
DELETE
2
& ,f§ E ⇒ ¥0www.af Raw Insert
£ 'D•
eO Rotation :
§to⇒§% Nodauteneeded ?a bbb bbBYEAb Dts
ORDER STATISTICS TREE (A. D.T. )✓a red - black tree
= BINARY SEARCH TREE that handles theseadditional operations in 0 Clog n ) time :
RANK ( ⑨ ①TPointa to root
Returns rank of\ mode in tree element a
( smallest = I
,
CLE ke n largest
= n )
SELE a- ( ⑧t ) Returns k-
th smallestitem in tree t
parent Ca )
Cella:
finna.
. . .
Size of subtree of x : Verify that we can still do INSERT,
DELETE in a red - black tree in
time 0 Clegal .
Verify that RANK,
SELECT can be
done in time Olly n ) .
INSERT,
DELETE
O ± ,
R node added or deleted :
I only nicely ), for y
Canasta ofa)Of' is affected , byte .Ottfteeedratiou :¥¥'÷. i..
Mr A is
A1¥only one mode changes its
"size
" field .
SELECTh -
th smallest
- root
if t= nil then return "nonsense
" I D.else if bftftt-niltkf.LI?afeeftfED+t/rEukoffot/case r=k : return A
k - r : return SELECT Ck, left- ft ] )k > r : return Sensei Ck - e
, right ft )
Time -- Olga)
RANKGO.to
not
Toothmode
b§#tavcbdlgyo_0
ifbftlxfzmlelheu b fo 'D
else 'D
yea D 'Dwhile yttdo :
if night fpareutly'D-_y
RANK - It
. -parent fit ]time -00gal
INTERVAL TREES
augmentedto deal with these operations :
redhead BEEF.
retard
MAKENULL
parentbe ]OVERLAP
, ④t ) : report. if internal i overlapswith
any giveninterval
CELL a
✓man high l . ] in subtree
- red .aaaaa qq.gg
leftby right la] Aall stores an intend flow,high ]
.
EXAMPLE
. 6¥."
a #
m
if Max = 18
ma a- 6
INSERT,
DELETE : Eggto update"
man"
.
All operations Olley a) .
OVERLAP,
(④wt"d_soot of tree e
.
ift -
- nil thenreturn"
no overlap"
hen jhE
else if i overlaps flow Ct ] , high Ct ] ] .
then return "
overlap"
else if left It I # nil and low GI
EmanI left
It] ]
then return OVERLAP- fi
, left It ] )else return OVER LAI Ii
, right Et] )
i 1¥ i
1-1 O 1-1 Two cases :
A
APPLICATION :
CHiPs OUTLAY DESIGN
a(a)
DETIRphimnirr-offffeu.ISOVER LAI in A COLLECTION
SWELL LINE ALGORITHM= interval tree
④I
t
Li
MAKEN U LL
Sort Cadi! , Bili ! .
K '
For all sorted elements,⇒qayeqs" sweep"
If element is some"
ai"
,then
if Ortrud ( bei, yil ,
t ) then exit"
overate"
else INSERT (Cai, y ;) ,
t )If element is some
"
Gi"
,then DELETE ( ( ni , yil ,
t )
Note Overlap occurs ⇒ at some point,two " line "
intervals overlap .
LEVEL LINKING IN RED BLACK TREES
Use : Browsing operations ( NEXT,
NEXT ok,
PreviousPREVIOUS - k )
Pringle :
°
RED-BLACK TREE / ) orLevel linking
O O
¥1I ) fleabag)0 O O 0 0KLAN:*
O ° 0 0 O 0 0 O 0 0
2-3-4 tree view
of a red -black tree
SEARCH FOR KEY
⑨WHEN AT a
, if L > key Ca)
assume they Cjfk
-
✓font overshoot of y
I-÷⇒IT'
Search:"" a A ::÷n¥ .
.¥-5 Down tog .
DX !gateau aegean
#
.
THEM# • I This ONE* . *.⇐÷÷÷i¥*÷÷⇒÷
LOOKING for
GOTOWARDS ROOT hey Cy ]UNTIL RIGHT - LEVEL
.
NEIGHBOR OVERSHOOTS
THEN DESCEND TO y ( STANDARD SEARCH )
TROUBLE ↳ : Time could be ④Heyn)
even thoughf Rankly) - Randal =L
.
I¥y
REMEDY : Maintain standard "meat"
list and do this :
ED nearest
(2) from a, find y as explained earlier .
←÷→%¥, Eseaasecbnd ) : Times
←÷ HOAG,(Rankly ) - Rankin ) )
.
k - d TREES Used to store data in RdFor partitions of Rd
1
At directions
→G,•
& " "at * s
¥µ¥7Y÷ay¥• " "
÷"§bbbm%"
\ -
in.÷⇒ %Mtgat # y my Lalorat # a
Leafq②
Binary Tree.
Operations : INSERT,
DELETE ,
2 - d Tree
SEARCH for Ca, y )
SEARCH for La,
* ) ! PARTIAL MATCH SEARCH
SEARCH for ( Ayy ) i " " "
REPORT all points in 1-Id :
a- .a
R= @by × fed ] RANGE SEARCH.
Range search :
Recursively visit all subtrees whoseregion
intersect . R
and catgut all points frig . ) that fall in R.
Outline of rangesearch
cellypareat
Given : rectangle R=↳p×↳d]
Dupontk -d trot left right
Range Search ( R ,t )
%ef-qqa.pe.
und
Ift # nil and
Ramattail react ]
then point a Rtheuotptpointct ]
Areact ]
. itrauge Search ( R, left ft )¥Y:"" " " '
↳ -
left
.TT#TightftT
QUAD TREES for point . in IRD i and-
anysearch trees
%÷÷.
Used in aaupta graphics .
Range search as far k -d trees
.
B SI TREES (Binary Space Partition Trees )= = =
Used to render Ipaint
fira screen ) a scene
been from a given viewpoint⑥
on/ameVIEWING D
ang ⇐§¥yg¥.
③ B
n .Egad
.
ahiesepsmgameetaasno. .
£-1.②
the BSI tree,
and separates the separate theobjects
region it delays to into two parts .
BSP tree-
t = side of viewer
/ \ -= far side
-02+035-
a mode correspondsta
- £¥ to a line segment
+ -
f k¥13 }•. -
object. are leaves
I IE D Pamtfonhm: Traverse in - t
order to render the objects .
•
Panning the viewingdirection : only flip some - t polarities .