---
title: "AVL tree for 52, 65, 72, 15, 11, 32, 20"
subject: "Data Structure and Algorithm"
chapter: 6
key: "semester_4/data_structure_and_algorithm:avl-build-52-65-72"
source: https://www.bctengineer.com/q/semester_4/data_structure_and_algorithm/avl-build-52-65-72
site: BCT Engineering
---

# AVL tree for 52, 65, 72, 15, 11, 32, 20

Data Structure and Algorithm · Chapter 6: Trees

- Asked in: 2071 Magh, 5 marks
- Video: [Lec-59: How to Create AVL tree | LL, RR, LR, RL Rotation in AVL | Data Structure](https://www.youtube.com/watch?v=vEZ3-bdPdUQ) — Gate Smashers
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/data_structure_and_algorithm/avl-build-52-65-72
- Whole chapter: https://www.bctengineer.com/md/semester_4/data_structure_and_algorithm/chapter-6

## Question

Construct an AVL Tree for given integers: 52, 65, 72, 15, 11, 32, and 20.

## Short answer

Final AVL tree: root 52, left child 15 (left 11, right 32 with left 20), right child 65 (right 72).

## Answer

Insert each key as in a BST and rebalance with rotations when a node's balance factor becomes ±2.

Balance factor of a node = height(left subtree) − height(right subtree). It must stay −1, 0 or +1. After each insertion, find the nearest unbalanced ancestor of the new node and fix it:

| Case | Where the new node went | Fix |
|---|---|---|
| LL | left subtree of left child | single right rotation |
| RR | right subtree of right child | single left rotation |
| LR | right subtree of left child | left rotation on the child, then right rotation |
| RL | left subtree of right child | right rotation on the child, then left rotation |

#### Step-by-step insertion

| Step | Insert | Tree after step (root(left,right)) | Imbalance / rotation |
|---|---|---|---|
| 1 | 52 | `52` | balanced |
| 2 | 65 | `52(-,65)` | balanced |
| 3 | 72 | `65(52,72)` | at 52: RR: left rotate at 52 |
| 4 | 15 | `65(52(15,-),72)` | balanced |
| 5 | 11 | `65(15(11,52),72)` | at 52: LL: right rotate at 52 |
| 6 | 32 | `52(15(11,32),65(-,72))` | at 65: LR: left at 15, right at 65 |
| 7 | 20 | `52(15(11,32(20,-)),65(-,72))` | balanced |

#### Final AVL tree

```text
52
├─L:15
│  ├─L:11
│  └─R:32
│     └─L:20
└─R:65
   └─R:72
```

Height = 4, and every node has balance factor −1, 0 or +1.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Inserting 72 into 52(-,65) unbalances 52. Fix?
   A. LL; right rotation
   B. RL; double rotation
   C. RR; left rotation at 52 giving 65(52,72)
   D. No fix
   Answer: C. 72 lies in the right subtree of the right child. (Key point: Insert 72)

2. Inserting 11 into 65(52(15,-),72) unbalances 52 (11 goes left of 15). Fix?
   A. RR; left rotation at 52
   B. LR; double rotation
   C. RL; double rotation
   D. LL; right rotation at 52
   Answer: D. 11 is in the left subtree of the left child. (Key point: Insert 11)

3. Inserting 32 into 65(15(11,52),72) unbalances 65. Which case and fix?
   A. LR: left at 15, right at 65
   B. LL: right at 65
   C. RL: right at 72, left at 65
   D. RR: left at 65
   Answer: A. 32 goes to the right subtree of the left child 15, so a double LR rotation gives root 52. (Key point: Insert 32)

4. What is the root of the final AVL tree?
   A. 65
   B. 52
   C. 15
   D. 32
   Answer: B. After the LR rotation the root is 52: 52(15(11,32(20,-)),65(-,72)). (Key point: Final tree)

## Related in Data Structure and Algorithm

- [AVL tree for 10, 20, 30, 35, 50, ...](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Aavl-build-10-20-30-35) — Data Structure and Algorithm, chapter 6
- [AVL tree for 24, 12, 8, 15, 35, ...](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Aavl-build-24-12-8) — Data Structure and Algorithm, chapter 6
- [AVL tree for 10 20 30 50 45 40 8 5 3](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Aavl-build-10-20-30) — Data Structure and Algorithm, chapter 6
- [B-tree of order 3 for 52, 46, 27, ...](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Abtree-order3-52-46-27) — Data Structure and Algorithm, chapter 6
- [AVL tree for 3, 2, 1, 4, 5, 6, 7, ...](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Aavl-build-3-2-1-4) — Data Structure and Algorithm, chapter 6
- [AVL tree for month names](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Aavl-build-months) — Data Structure and Algorithm, chapter 6, asked 2×

## Related in other subjects

- [32:1 MUX tree; implement Σm(0,1,3,8,9,13,15)](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Amux-32to1-tree-function-15) — Digital Logic, chapter 4
- [Class C pool for 32, 65, 10, 21, 9](https://www.bctengineer.com/question.md?key=semester_7%2Fcomputer_networks_and_security%3Asubnetting-class-c-five-depts) — Computer Networks and Security, chapter 4, asked 2×
- [32:1 MUX tree from 4:1; implement Σ(0,1,3,8,9,13)](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Amux-32to1-tree-function) — Digital Logic, chapter 4
- [1:32 DEMUX tree from 1:8 and 1:2 DEMUXes](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Ademux-1to32-tree) — Digital Logic, chapter 4
