21
ASSALAMU ALAIKUM Hello Everyone Welcome to Our Presentation

Splay tree && euler tour tree

Embed Size (px)

Citation preview

Page 1: Splay tree && euler tour tree

ASSALAMU ALAIKUM

Hello Everyone Welcome to Our Presentation

Page 2: Splay tree && euler tour tree

Presented By

▪ Md. Hasan Ali

▪ Md. Rezwanul Haque

▪ Nayan Kumar Rudro

Page 3: Splay tree && euler tour tree

Presentation Topics Splay tree & Euler tour tree

Page 4: Splay tree && euler tour tree

What is SPLAY TREE ?

▪ The splay tree was invented by Daniel Dominic Sleator and Robert Endre Tarjan in 1985.

▪ Splay trees are self branching binary search tree which has the property of reassessing the elements quickly that is recently accessed.

▪ The performance of the Splay trees depends on the self balancing and self optimizing.

▪ The worst case with this splay tree algorithm is that this will sequentially access all the elements of the tree which makes tree unbalanced.

Page 5: Splay tree && euler tour tree

What is Self Branching ?

5 10

15

3

5

10

10

5

15

15

10

5

3

15

3

5

10

3

3

15

5

10

Page 6: Splay tree && euler tour tree

Real Time Applications

It is used to implement Caches.It has the ability of not to store any

data, which results in Minimization of memory requirements.

It can also be used for data compression, e.g. Dynamic Huffman coding.

Page 7: Splay tree && euler tour tree

Advantages & Disadvantages

Advantages: It is easy to implement than other self branching

binary search trees ,such as Red black trees or AVL trees .Much simpler to code than AVL, Red Black trees.

It requires less space as no balance information is required.

Disadvantages: More local adjustments during Search operations. Individual operations can be expensive , Draw

back for real-time applications. The main disadvantage of Splay trees is the

height . After accessing all ‘ n ‘ elements in the tree ,The height of the tree corresponds to worst case access time.

Page 8: Splay tree && euler tour tree

Operations

The main basic operations of the Splay tree are Search Insert Delete Splaying

Search , Insert , Delete operations are like in Binary Search trees, except at the end of each operation ,a special step called Splaying is done .Splaying the tree rearranges the tree so that element is placed at the root of the tree .It uses tree rotations to bring the element to the top.

Page 9: Splay tree && euler tour tree

When to Splay?

Search :Splay node where key was found.

Insert :When an item is inserted ,a Splay is performed .As a result , the newly inserted node becomes the root of the tree.

Delete :Splay parent of removed node which is either the node with the deleted key or its successor.

Page 10: Splay tree && euler tour tree

Splaying

There are three types of Splay steps are Zig step Zig-Zag step Zig-Zig step

Page 11: Splay tree && euler tour tree

Zig step

P

X

P

X

P

X

P

X

Page 12: Splay tree && euler tour tree

Zig-Zag step

P

P

G

X

P

G

X

X

G

P

X

G

P

X

GG

X

P

Page 13: Splay tree && euler tour tree

Zig-Zig step

P

G

X

P

G

X

P

G

X

P

G

X

Page 14: Splay tree && euler tour tree

Example

5 10

15

3

5

10

10

5

15

15

10

5

3

15

3

5

10

3

3

15

5

10

Page 15: Splay tree && euler tour tree

Results of Splaying

The result is a binary tree , with the left sub tree having all keys less than the root ,and the right sub tree having keys greater than the root.

The resulted tree is more balanced than the original tree.

If an operation near the root is done ,the tree can become less balanced.

Page 16: Splay tree && euler tour tree

TIME COMPLEXITY

For ‘ m ‘ operations to be performed on splay tree it requires O( mlogn) steps where n is the size of the tree . On an average the time complexity of each operation on the splay tree is :

Search : Searching for a node in the tree would take O( logn).

Insert :Inserting a node in to the tree takes O( logn).

Delete : Deleting a node from the tree takes O( logn).

Page 17: Splay tree && euler tour tree

Euler Tour Tree

Who Invented Euler Tour Tree?Euler Tour Tree was invented by Leonhard Euler.

What is Euler Tour Tree?A data structure for Dynamic Connectivity

What is Dynamic Connectivity?Maintaining connectivity in a changing

environment.

Page 18: Splay tree && euler tour tree

How it Works?

S

1 53

42

6

Output : 1 2 6 6 2 4 4 1 3 3 5 5

Page 19: Splay tree && euler tour tree

Application

•Dynamic Trees as Search Trees Via Euler Tours.

•Applied to the Network Simples Algorithm.

Page 20: Splay tree && euler tour tree

Do you have any Question?

Feel free to ask any of us

We will try our Best to Answer.

Page 21: Splay tree && euler tour tree

Thanks to

Each && Everyone.