📘 PAPER 4 – DESIGN & ANALYSIS OF ALGORITHMS (UNIT 2 – ADVANCED DATA STRUCTURES) university of allahabad

 

🔴 UNIT 2 – ADVANCED DATA STRUCTURES


1️⃣ AVL TREE (Adelson–Velsky and Landis Tree)

✅ Definition

An AVL Tree is a self-balancing Binary Search Tree (BST) where the height difference (balance factor) of left and right subtrees is at most 1.


✅ Balance Factor (BF)

BF=Height(left subtree)Height(right subtree)BF = Height(left\ subtree) - Height(right\ subtree)

Allowed values:

  • -1

  • 0

  • +1


✅ Rotations in AVL Tree

When balance factor becomes ±2, rotations are performed.


🔹 Types of Rotations

1. LL Rotation (Left-Left)

Occurs when:

Single right rotation


2. RR Rotation (Right-Right)

Occurs when:

  • Insertion in right subtree of right child

✔ Single left rotation


3. LR Rotation (Left-Right)

Occurs when:

  • Left child has right-heavy subtree

✔ Left rotation + Right rotation


4. RL Rotation (Right-Left)

Occurs when:

  • Right child has left-heavy subtree

✔ Right rotation + Left rotation


✅ Advantages

✔ Balanced tree
✔ Faster searching
✔ Time complexity: O(log n)


2️⃣ Red-Black Tree

✅ Definition

A Red-Black Tree is a self-balancing BST where each node is colored either red or black.


✅ Properties

  1. Every node is red or black

  2. Root is always black

  3. Red node cannot have red child

  4. Every path from root to NULL has same number of black nodes

  5. Leaf nodes are black


✅ Advantages

✔ Less rotations than AVL
✔ Faster insertion and deletion
Used in STL, Java TreeMap


🔹 Comparison: AVL vs Red-Black Tree

FeatureAVL TreeRed-Black Tree
BalancingStrictLess strict
SpeedFaster searchFaster insert/delete
RotationsMoreLess
UseSearch-heavyInsert-heavy

3️⃣ B-Trees

✅ Definition

A B-Tree is a self-balancing tree designed for disk storage systems.


✅ Properties


Order of B-Tree (m):


Example:

B-Tree of order 3:

  • Max keys = 2

  • Min keys = 1


Advantages:

✔ Reduces disk access
✔ Balanced structure
✔ Efficient searching


4️⃣ Binomial Heap

✅ Definition

A Binomial Heap is a collection of binomial trees.


Properties:


Operations:

  • Insert

  • Merge

  • Delete minimum

  • Find minimum


Time Complexity:

OperationTime
InsertO(log n)
MergeO(log n)
Delete minO(log n)

5️⃣ Fibonacci Heap

✅ Definition

A Fibonacci Heap is an advanced heap structure used in graph algorithms.


Advantages:

✔ Faster decrease-key operation
✔ Used in Dijkstra & Prim algorithms


Time Complexity:

OperationTime
InsertO(1)
Decrease keyO(1)
Extract minO(log n)

6️⃣ Comparison of Heaps

FeatureBinary HeapBinomial HeapFibonacci Heap
InsertO(log n)O(log n)O(1)
Delete MinO(log n)O(log n)O(log n)
MergeO(n)O(log n)O(1)
ComplexitySimpleModerateComplex

📌 EXAM IMPORTANT QUESTIONS (UNIT 2)

✔ Explain AVL Tree with rotations
✔ Explain Red-Black Tree
✔ Difference between AVL & RB Tree
✔ Explain B-Tree
✔ Explain Fibonacci Heap
✔ Applications of heaps

Comments

Popular Posts