0% found this document useful (0 votes)
142 views

Lect12 Scapegoat Slides

Scapegoat trees are self-adjusting binary search trees that perform rebalancing operations during insertion to avoid degradation in performance over many insertions and deletions. The key aspects are: 1) During insertion, a "scapegoat" node whose subtree is most unbalanced is identified and its subtree is rebuilt to rebalance the entire tree. 2) This rebuilding is done through rotations, similarly to AVL and red-black trees, but occurs less frequently in an amortized sense. 3) Finding and insertion operations take O(log n) time on average through periodic rebuilding, even after many updates, making scapegoat trees efficient for dictionaries.

Uploaded by

rashed44
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
142 views

Lect12 Scapegoat Slides

Scapegoat trees are self-adjusting binary search trees that perform rebalancing operations during insertion to avoid degradation in performance over many insertions and deletions. The key aspects are: 1) During insertion, a "scapegoat" node whose subtree is most unbalanced is identified and its subtree is rebuilt to rebalance the entire tree. 2) This rebuilding is done through rotations, similarly to AVL and red-black trees, but occurs less frequently in an amortized sense. 3) Finding and insertion operations take O(log n) time on average through periodic rebuilding, even after many updates, making scapegoat trees efficient for dictionaries.

Uploaded by

rashed44
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

- ,

"t
scapegoat Trees :
Recap :
Example :

Arne Anderson ( 1989 ) seen search trees


many
-
-

p
:

Met

-

Galperin - Rivest 4993 ) -

Restructure via rotation '


rediscovered extended -

Today : Restructure via ⑨ Q t


i=l"4=3
Amortized analysis
rebuilding ,②
)
-

Ollogn ) for dictionary -


sometimes rotation not
② ④ y
ops
amortized possible ,②
¥2
,

-
( guaranteed for find ) .
-

Better Mem .

usage . .

tubeetrethi :%k%%% ¥701


§a
,

overview
-

:
rebuild it

¥
IScapegqattreesfg.ua
'
tune -
-

,

How to rebuild ?
Time Olk )

n
Insert : .

¥
standard
' t
rebuild ( p)
.

same BST :

siiobrdeeetwaerteagicsf
as
-

itdeprtachetsoearhcishpath Dek.tseaimea.std.net f
"
-

- '
- '

back -

Ifnum - of deletes is build subtree CA)


-

find unbalanced

|sRrfubrhildfybetreeY¥Im)
-

large rel .to n -


build subtree ( ACO Kid) . .
:

node -

scapegoat rebuild entire tree ! -

ifk o return null


-

rebuild this subtree How ?


Maintain n ,m←o -

j ← Lklz ) ;x←A median


Find : same as stdtsst Insert : htt ,mtt -

hc-buildsubtreelAEO.j.IT )
heights log
Tree
.hn?.7lgnDelete:mn-szn-YeIbfuiid
-

.
- ,

!÷÷÷÷ .÷÷÷÷÷÷÷i÷÷
Insert : - T_ Details of Operations :
Example ,⑤ : .

1120 ⑤

fit
.

htt ; Mtt

stdtsst but Init root ← null IQ


.

'
h←m←o
,⑨ ④
:
same as
-

keep track of inserted Delete TO ⑤



:

node 's depth


'
d - -

Same as std DST


j⑨ % ④ ,

:¥÷÷÷÷÷÷:* :* . .

.
iii.
vnisoidtesdinsnjg.ly?jljngeoftscapegozttreeswT
-

for each node p ④ n 'll

rial

if sizecp child ) > I


" - -
-
"

proof contradiction
g
By
§
-

.
Lau :

Tip ¥ . Must there be a ¥ .

Pichi 'd
depth

.fi:92www.?ayge. -ysj:. )9yoa.gD:dK/nesnca-pegoat


P.ofiedeg.thcaondiniesttioornJQo
scapegoat ? yes ! Suppose 's >

logger
-

p
rebuild Lp
'

nwwde
?
V-ancestorsn-break-sjapegoat.rs
pc but
-

. ,

binanymfd.ph
.

Lemma Given a izelu child )s


us,
: .

D with n nodes if Ztsisizelu )


⇐ tree ,
o -

o
-
n

has
catchiest
"
' ?
-
While
backing out , traverse
605 otp that satisfies Q i
.
zssizecpk.FI
other sibling Eh)dsn
"
"

Too

slow ? No !
charge to rebuild .
go
.
d> loyz.no/psfs)dn dsl0$%n,
- ,

¥9
t.ie#ttreeswMol e e -

-
Theorem :
Starting with an
empty tree ,
.

any sequence
of m
dictionary operations
tree take time
on a
scapegoat )]
0cm log m ) [Amortized OC :

login
Proof ( sketch )
:

Find O Clog:
n ) guaranteed [ Heights Olbgn ))
Delete : In order to induce a rebuild ,

number of deletes number of n

.
.
nodes in tree . .

→ Amortize rebuild time against


delete ops
Insert Based :
on potential argument
→ It takes n k ops to cause a
subtree to size unbalanced
K to be .

rebuild time to these



charge
operations
°
,

You might also like