/
1 Self-Adjusting 1 Self-Adjusting

1 Self-Adjusting - PowerPoint Presentation

natalia-silvester
natalia-silvester . @natalia-silvester
Follow
391 views
Uploaded On 2017-05-17

1 Self-Adjusting - PPT Presentation

Data Structures SelfAdjusting Data Structures 2 Lists DD Sleator RE Tarjan Amortized Efficiency of List Update Rules Proc 16 th Annual ACM Symposium on Theory of Computing 488492 1984 ID: 549265

heaps meld zig search meld heaps search zig trees splay paths binary path zag adjusting light log root sleator

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "1 Self-Adjusting" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

1

Self-Adjusting

Data

StructuresSlide2

Self-Adjusting Data

Structures

2

Lists

[D.D.

Sleator, R.E. Tarjan, Amortized Efficiency of List Update Rules, Proc. 16th Annual ACM Symposium on Theory of Computing, 488-492, 1984]Dictionaries[D.D. Sleator, R.E. Tarjan, Self-Adjusting Binary Search Trees, Journal of the ACM, 32(3): 652-686, 1985] splay treesPriority Queues[C.A. Crane, Linear lists and priority queues as balanced binary trees, PhD thesis, Stanford University, 1972][D.E. Knuth. Searching and Sorting, volume 3 of The Art of Computer Programming, Addison-Wesley, 1973] leftist heaps[D.D. Sleator, R.E. Tarjan, Self-Adjusting Heaps, SIAM Journal of Computing, 15(1): 52-69, 1986] skew heaps[C. Okasaki, Alternatives to Two Classic Data Structures, Symposium on Computer Science Education, 162-165, 2005]  maxiphobix heaps Okasaki: maxiphobix heaps are an alternative to leftist heaps ... but without the “magic”

7

4

2

3

5

9

1

Search

(2),

Search

(2),

Search

(2

) ,

Search

(5), Search(5), Search(5)

2

7

5

3

9

1

4

move-to-frontSlide3

=

Meld ( , )

Meld (

, )

Meld ( , ) = [C.A. Crane, Linear lists and priority queues as balanced binary trees, PhD thesis, Stanford University, 1972][D.E. Knuth. Searching and Sorting, volume 3 of The Art of Computer Programming,Addison-Wesley, 1973]MakeHeap, FindMin, Insert, Meld, DeleteMin3

Heaps

Meld Cut

root + Meld

==

(via

Binary

Heap-Ordered

Trees)

Maxiphobic Heaps

T

3

y

T

1

T

2

x

T

i

T

j

T

k

x

largest

size

two

smallest

Max

size

n

n

Time O(log

3/2

n

)

Each node

d

istance to empty leaf

Inv.

Distance right child

 left child

rightmost

path

log

n

+1 nodes

5

2

3

4

6

8

10

11

13

9

7

12

13

1

1

1

1

1

1

2

2

1

2

2

3

1

x

<

y

[C

.

Okasaki

,

Alternatives to Two Classic Data

Structures

,

Symposium

on Computer Science Education,

162-165

, 2005]

Leftist Heaps

4

7

9

13

2

2

2

4

1

1

1

2

3

3

3

1

4

13

2

1

2

7

9

2

2

4

1

1

2

3

m

erge

rightmost

paths

Time O(log

n

)Slide4

Meld ( , ) =

[D.D.

Sleator

, R.E.

Tarjan

, Self-Adjusting Heaps, SIAM Journal of Computing, 15(1): 52-69, 1986]4Skew HeapsMeld Cut root + Meld==O(log n) amortized MeldHeavy right child on merge path before meld  replaced by light

child

 1 potential released

for heavy node amortized cost 2∙ # light

children on rightmost paths

before meld

4

7

9

13

2

4

13

7

9

2

m

erge

rightmost

paths

Heap

ordered

binary

tree

with

n

o

balance information

MakeHeap

,

FindMin

,

Insert

,

Meld

,

DeleteMin

Meld

=

merge

rightmost

paths

+

swap

all

sibling

s

on

merge

path

v

heavy

if

|

T

v

| > |

T

p

(

v

)

|/2,

otherwise

light

any path

 log

n

light

nodes

Potential  = # heavy right

children in tree

5

2

3

4

6

8

10

9

7

12Slide5

Meld (

, ) =

[D.D.

Sleator

, R.E.

Tarjan, Self-Adjusting Heaps, SIAM Journal of Computing, 15(1): 52-69, 1986]5

Skew

Heaps – O(1) time Meld

O(1) amortized Meld

Heavy right child on merge path

before meld  replaced by light child  1 potential

releasedLight nodes disappear from major paths (but

might  heavy)   1 potential released

and become a heavy or light right children on major

path  potential increase by  4

O(log n) amortized DeleteMin

Cutting root  2 new

minor paths, i.e.  2∙log

n new light children on

minor & major paths

4

7

9

13

2

4

13

m

erge

rightmost

paths

Meld

=

Bottom

-

up

merg

of

rightmost

paths

+

swap

all

sibling

s

on

merge

path

7

9

2

1

1

5

8

11

6

3

not

touched

previously

minor

4

2

1

11

6

3

5

8

minor

major

 = # heavy right

children in tree + 2 ∙

# light children on minor & major path

=

4

5Slide6

6

[D.D.

Sleator

, R.E.

Tarjan

, Self-Adjusting Binary Search Trees, Journal of the ACM, 32(3): 652-686, 1985]Splay TreesBinary search tree with no balance informationsplay(x) =

rotate x to root

(zig/zag,

zig-zig/zag-zag, zig-zag/zag-zig)

Search (splay)

, Insert (splay predecessor+new root), Delete

(splay+cut root+join), Join (splay max, link), Split (

splay+unlink)

B

y

A

x

C

C

x

B

y

A

zig

B

y

A

x

C

D

y

C

z

B

zig-zig

z

D

x

A

C

y

B

x

A

D

x

C

z

B

zig-zag

z

D

y

A

root

D

y

C

x

B

v

F

z

A

u

E

B

x

A

z

C

zag-zag

zig-zig

F

u

E

v

D

y

B

x

A

z

C

F

u

E

v

D

y

insertSlide7

7

[D.D.

Sleator

, R.E.

Tarjan

, Self-Adjusting Binary Search Trees, Journal of the ACM, 32(3): 652-686, 1985]Splay TreesThe access bounds of splay trees are amortized (1) O(log n) (2) Static optimal (3) Static finger optimal (4) Working set optimal (proof requires dynamic

change of weight

)

Static optimality:  = v log |

Tv|