0% found this document useful (0 votes)
59 views4 pages

Lect13 Weight Bal Slides

- This document discusses splay trees, which are self-adjusting binary search trees that provide optimal access to frequently accessed data. - Splay trees move frequently accessed elements closer to the root through a process called "splaying." After each access, the accessed node is moved to the root by performing rotations. - This optimizes access by reducing the depth of frequent elements, keeping the tree nearly height-balanced and achieving search times close to optimal.

Uploaded by

rashed44
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views4 pages

Lect13 Weight Bal Slides

- This document discusses splay trees, which are self-adjusting binary search trees that provide optimal access to frequently accessed data. - Splay trees move frequently accessed elements closer to the root through a process called "splaying." After each access, the accessed node is moved to the root by performing rotations. - This optimizes access by reducing the depth of frequent elements, keeping the tree nearly height-balanced and achieving search times close to optimal.

Uploaded by

rashed44
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

- ,

weight Balance : Overview :


Implementation :( as extended BST)
-

Given asetof keys


-

splay trees -

Static

stores'D
X={ Xo Internal node
,xn , } Optimality :

accessed
. . .

,
.

(
-
and values -

More
frequently key key
float wt

splitter
closer to root → total
Ivo ,
. . .
.vn .
,
) keys j
-
and
weights weight -

balanced weight of ax xx

Tv two } in subtree
trees
-1
entries

1$
-

,
. . . .
,wn .
,
-

Assume : left right

iesttiesataedwm syoaii.ea.awei.I.iq
. . . .

xosx ,s . . . -

sxn sorted External Node :


.

key key
'

④ positivity
> o
Wi ,

pseudo -

probability :

Let
-
: =

wi total weight ¥5
Given Yeast ,aBsT
-

Let :pi=WiFw pseudo prob -


How to (
Nearly) Achieve is a balanced if
-

Obs discrete Shannon 's bound for all internal nodes p


:& ? ; ! ! } }
-

.
. . .

prob Weight -
balanced balance ( ) sa
p
distribution

.

tree
9=42
Perfectly balanced

{ tathekastfropyipoiflgj!P.in#alledT/balancelpg=maxlwtlp.let l.wt-p.rightDa--4s
Shannon 's Theorem :
Ifpi is → For each node p :
:

the prob .
of
accessing search
Xi , wtlp) total-

weight =L :

Arbitrarily bad
Bst has expected of nip 's
keys subtree
any
:b reasonable
wtlp ) compromise
.-wt .
- -

ideal
Ax How to ksb
Balance by Rebuilding maintain balance ? Example
:

:%/Iµµ/-%
:oi_
:

Given an array Alo


of external nodes :
. .
let ] Option's
-
:

Rotations Similar to :
utile
key

.is/ltnt4H3t2t4YJ.wsY6Ali3.wt
Ali] key Dm Ali) value AVL trees (
singles double)
b
. -

, .

. .
-

→ BBK ) trees =3

Assume Keys are sorted -

Rebuild subtrees Similar : t.buifralalo.zDR-buildtreelAG.is'D


weights to
scapegoat
get
Assume > o return
I
-
.

$9
.

⑤ .
m.

saetestrgetiteerigtodm.in#emi:neahTreesEmEt
.

weight -

based median :
'
weight -

Balanced Q①
-

add a :O
Let Ali] .wt Total wt build Tree ( Alo K D) i

.az#:nne*/-Goal:Splitatosjskthal-

-

- = . -

Iii : Iii?jt←o¥%÷tj iflk-tretvrna.co/x.basecase*l


A oT--EiijAli3't.wt
'

Letwin .
-

,]
weight total
Rwtsto;Dm IT

is"÷÷÷÷÷÷÷
.
Init : b=o ; Lwt -
-
O;
,

..
.
.
.

"
..

%fbfifgf emgyn.to?j.i j Ammi=D3


minimizes :
¥:*
Amin Aj Most balanced split
org
-
-

.

t-Test !?CEi
"

Q R
-
-

buildtreelacb.k.is)
A return new Int Node ( Alb] key ,L,R )
#Esphthe .
. i t
.
- ,


Butitis pretty close ! Analysis : Bad weight distributions ?
Ifa weight is
Does this algorithm produce -

very large
Theorem :( Mehlhorn 'M ) the optimal tree Curt .
expected relative to neighbors ,

The above balanced split case search time ) ? rebalance maybe ineffective
algorithm produces a tree

÷÷ µ-
be - d
The optimal
""

whose exp search time is



.
-

No .
BST can

computed by dynamic programming


SH -13
t⑧ Lemma : weights are
)
the:c.tn:c:*:*: nisig.EE?a-n7w7
- . .

says ,
where H bound much
" "

( not too
entropy

Lionizing
-
. nice

variation) inserts delete ,

,
rebuilding Jackhammer
-

Trees .
-

Checks Rebuild : .
-
*
Ifnosuohp found -

÷ ÷
Find from Great ! Tree is balanced
Same usual Tree when
returning
:
as -

:
.

heights log%n,soO4ogn ) Jackhammer !


:

.
: recursive calls update .

÷
Else :
,
. .

time
guaranteed
-

i each node 's


weight ;
-

Traverse
p
's subtree
: p.wt-p.left.wttp.right.int : in order, store extern
InsertDelete : Start same as
:
i -

starting at root walk down ,


: nodes in
array
Alak D -

standard BST
i
search path Stop at first Replace 's subtree
! p
-

completes
'

After operation node pst with

qq.gr?er..-.s.ba1anoecp g÷9÷÷}!I¥7÷i

i .

checks rebuild " "


"

buildtreeln)
, >

°
,
- ,

when to rebuild ?
Dictionary Operations

f÷ ÷ ÷ ÷ i
very heavy entries : :

If an
entry 's weight
-

"

backing
"

is too
high rebuilding
,
-

find :
as usual -

when out

is ineffective -
insert insert as usual
: from insertldelete ,

Example ynutbarlghelp
niidnig !
but rebuild if needed update
walk down
node
weights
search
, doesn't -
delete delete as usual:
-

but rebuild if needed path from root


"

÷ :÷÷÷÷÷÷÷÷÷÷÷i÷ .
( a. P ) balance
-

and -

For node p :
maxcpt
-
:

Every max -
ratio (p )sp
subtree internal node either
.
max
weightings's p is then : .

maxlp ) x -

balanced on

Max ratio ( pls -

p exempt
-
-

Rebuild p :
(
-

)
weight P
Lemma : For set of
'

Traverse pisubtreeinorder
any
Given parameter Opal , weighted entries ,
Jan -

collect external nodes in .

anmodae.irsafioefsm.pt
't

°
.fi?idtreeunp--Y4
,
remain : 'm
-

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy