1

I just finished an exam on this, where I used an inorder traversal to check correct node order in one of my splay trees. Is this valid?

Chicken Crimpy
  • 91
  • 1
  • 2
  • 6

1 Answers1

1

Yes, in-order traversal accesses a splay tree's elements in increasing order.

By the definition of a splay tree in the original article:

The splay tree, (is) a self-adjusting form of binary search tree

So, a splay tree is just a regular binary search tree by structure, which is all that is required for in-order traversal to access elements in increasing order. Apart from that, operations along the search path of a splay tree modify the structure, but they do so in a way which doesn't violate the binary search tree invariants.

Ami Tavory
  • 74,578
  • 11
  • 141
  • 185