1. Skewed Binary Search Tree (BST)

A skewed BST is a binary search tree where nodes are inserted in such a way that all nodes go only to one side—either all left or all right. This makes the tree behave like a linked list.

Example:

Left-skewed:

     50
    /
   40
  /
 30

Right-skewed:

10
  \\
   20
     \\
      30

Time Complexity:

Since the tree becomes like a list, the height of the tree becomes n. So operations like insertion, deletion, and search take O(n) time.


2. Balanced BST (AVL Tree)

An AVL Tree is a self-balancing BST where after each insertion or deletion, the balance factor is checked and rotations are performed if needed.

Balance Factor:

Balance Factor = height of left subtree - height of right subtree

It must be -1, 0, or 1 for every node.

Rotations:

  1. Right Rotation (LL case): Used when left subtree is heavy.

Example:

Inserting 30, 20, 10

Before:
     30
    /
  20
 /
10

After right rotate:
     20
    /  \\
  10   30