3

I have read about Splay tree and I found,there are two methods for constructing the splay tree. They are

  1. Bottom-up
  2. Top-down

So I need to know What is the difference between the two methods and their working ?

Manjunath N
  • 1,365
  • 11
  • 22
Bhuvanesh
  • 1,269
  • 1
  • 15
  • 25

2 Answers2

1

A top-down splay tree: performs rotations on the initial access path. Thus a top-down splay tree node does not need a parent link. The splay operation finishes as soon as the search does. That means the overhead for operations of a top-down splay tree is of a relatively small amount.

Bottom-up splay tree: requires a traversal from the root down the tree and then a bottom-up traversal to implement the splaying step, so a bottom-up splay tree implementation looks similar to that of an AVL tree. Besides, it needs a parent link or a stack to store the search path.

An implementation of a top-down splay tree can be found in the data structure book (Chapter 12) written by Weiss.

Yossarian42
  • 1,950
  • 17
  • 14
0

The methods define how you use splaying when searching:

Bottom-up: you search the tree and rotate at the same iteration

Top-down: you first search and at another iteration you rotate

you can read Splay tree

This ideas hold to the creation also, when using the top down you insert the key as if it was a binary serach tree and than move it to the head in another iteration.

Lrrr
  • 4,755
  • 5
  • 41
  • 63
antonpuz
  • 3,256
  • 4
  • 25
  • 48
  • 9
    huh I thought bottom-up is two passes (first traverse tree as a BST then rotate one node backward until it becomes the root) and top-down is one pass (rotate inplace while traversing the tree) – hlide May 10 '15 at 22:58