More on BST


Self-Balancing Binary Search Tree

self-balancing binary search tree or height-balanced binary search tree is a binary search tree that attempts to keep its height, or the number of levels of nodes beneath the root, as small as possible at all times, automatically.
  • operation time directly proportional to tree's height, so keep the height small
  • One Idea: if know data ahead of time --- randomize its insertion into the tree to avoid tree becomming like a linked list
    Problem: ...data is dynamic...comming in over time

  • Another Idea:performing alteration of tree (such as tree rotations) at key times to reduce the height. Overhead involved.
    Tree Rotation
    • A tree rotation moves one node up in the tree and one node down.
    • Shape of the tree changes with the goal of decreasing its height.
    • Choose the nodes to swap such that you are moving smaller subtrees down and larger subtrees up resulting in improved balance and hence performance of tree operations.
    • RESULT:What happens when a sub tree is rotated is that the sub tree side upon which it is rotated decreases it's height by one node whilst the other sub tree increases it's height.