Tango Tree Data Structure

Tango Tree is an online algorithm. It is a type of binary search tree. It is better than the offline weight balanced binary search tree as it achieves a competitive ratio of O(log{ }log{ }n) as compared to competitive ratio of O(log n) of offline weight balanced binary search tree. It takes only O(log{ }log{ }n) of additional bits of memory at every node of the tree to increase the performance over weight balanced binary search tree.
Tango tree is conceptually a tree of trees as it partitions a binary search tree into preferred paths and non preferred paths and these preferred paths are themselves stored in the form of auxiliary trees.

Preferred child and Preferred Paths
Preferred child of any node of Tango tree is defined as the most recently touched child by a normal binary search tree lookup technique. Elaborating more on preferred child let us assume a subtree T rooted at node n with right child as p and left child as q. Call p as the preferred child of n if most recently accessed node of subtree rooted at n is present in the subtree rooted at p.
A Preferred path is defined as the path starting from root node and following all the preferred children along a path to reach a leaf node.


Tango Tree

Auxiliary Trees for Preferred Paths
A preferred path is represented by storing the nodes of the preferred path in a balanced binary search tree specifically red black tree. Then, for every non-leaf node of path P there is a non-preferred child q. This non preferred child acts as the root of the new auxiliary tree and then attach this new auxiliary tree rooted at q to its parent and in this way, it is easy to link the auxiliary trees together. There is also option to store some extra information in each node of the auxiliary tree as per our own needs like minimum depth of the nodes in the subtree below it, etc.

Operations on Tango Tree
The two most common operations on Tango Trees are Searching and Updating