splay trees Flashcards

1
Q

splay tree property

A

Data more recently accessed is near the root

The operation on each element will rearrange the tree so that this element will be placed at the root of the tree

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

zig

A

right rotation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

zag

A

left rotation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

zig-zig

A

right-right rotate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

zag-zag

A

left-left rotate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

zig-zag

A

right left rotate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

zag-zig

A

left right rotate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Splay Operations: Find

A

Find the node in normal BST manner
Splay the node to the root

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is amortized analysis?

A

In Amortized Analysis, we analyze a sequence of operations and guarantee a worst-case average time which is lower than the worst-case time of a particular expensive operation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

splay tree algorithm analysis

A

Worst case time is 𝑂(𝑛)

Amortized time for all operations is 𝑂(log⁑𝑛)
a sequence of 𝑀 operations on an 𝑛-node splay tree takes 𝑂(𝑀 log⁑𝑛) time.
Maybe not now, but soon, and for the rest of the operations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what is the final depth of a node on the splay path?

A

If a node on the access path is at depth 𝑑 before the splay, it’s final depth ≀3+𝑑⁄2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

splay tree insert and delete

A

Insert x
Insert x as normal then splay x to root.

Delete x
Find x
Splay x to root and remove it
Splay the max in the left subtree to the root
Attach the right subtree to the new root of the left subtree.

𝑂(𝑛2) time for 𝑛 inserts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly