Data Structures and Algorithms: the questions likely to come
91 analyzed questions from 13 past papers (5 board exams, 2078-2082), grouped by syllabus unit — each with its probability, how often it's been asked, and where to study the answer.
What is AVL tree. Construct AVL tree for the sequence 23, 30, 39, 11, 7, 17, 28, and 18. (1 + 5)
AVL Tree
An AVL tree is a self-balancing binary search tree in which, for every node, the heights of its left and right subtrees differ by at most 1. The balance factor must be in . After every insertion/deletion that violates this, balance is restored by one of four rotations: LL (single right), RR (single left), LR (left-right), RL (right-left). This guarantees height , so search/insert/delete are .
Construct AVL Tree for: 23, 30, 39, 11, 7, 17, 28, 18
Insert 23, 30:
23
\
30
Insert 39 — 23 becomes unbalanced (BF = -2), right-right case → RR rotation (left) about 23:
30
/ \
23 39
Insert 11, 7 — inserting 7 makes 23 unbalanced (BF = +2), left-left case → LL rotation (right) about 23:
30
/ \
11 39
/ \
7 23
Insert 17 — goes left of 23. Check ancestors: node 11 has BF = +1, node 30 has BF = +2 (left heavy) and the insertion is in the left subtree's right side → LR case. First left-rotate 11, then right-rotate 30:
23
/ \
11 30
/ \ \
7 17 39
Insert 28 — goes left of 30 (right child of 23). Tree stays balanced (all BFs in range):
23
/ \
11 30
/ \ / \
7 17 28 39
Insert 18 — goes right of 17. Now check ancestors of 18: node 17 BF = -1, node 11 BF = -2 (right heavy) and insertion is in the right subtree's left side → RL case about 11. First right-rotate 17... since 17's right child 18 is the imbalance, RL = right-rotate(17's child) then left-rotate(11). Result lifts 17 up:
23
/ \
17 30
/ \ / \
11 18 28 39
/
7
Final AVL Tree
23
/ \
17 30
/ \ / \
11 18 28 39
/
7
Verification of balance factors:
- 7: leaf, BF = 0
- 11: left height 1, right 0 → BF = +1 ✓
- 18: leaf, BF = 0
- 17: left height 2, right 1 → BF = +1 ✓
- 28, 39: leaves, BF = 0
- 30: BF = 0
- 23 (root): left height 3, right height 2 → BF = +1 ✓
All balance factors lie in , so the tree is a valid AVL tree.
Trees and Graphs
What is AVL tree. Construct AVL tree for the sequence 23, 30, 39, 11, 7, 17, 28, and 18. (1 + 5)
Define minimum spanning tree. Explain Prim's algorithm to find minimum spanning tree with suitable example. (1 + 5)
Use Dijkstra's shortest path algorithm to find the shortest path between the vertices a and z in the graph given below. (6)
Graph (undirected, weighted) with vertices a, b, c, d, e, z and edges: a–b = 2, a–c = 3, b–d = 5, b–e = 2, c–e = 5, d–e = 1, d–z = 2, e–z = 4.
Starting with empty binary search tree, show the effect of successively adding the following numbers as keys: 20, 23, 10, 21, 30, 15, 5, 22 and 40. Also, traverse this tree in preorder and postorder. (4 + 2)
Define spanning tree and minimum spanning tree. Explain Kruskal's algorithm to find minimum spanning tree with suitable example. (2 + 4)
What is spanning tree? Explain minimum spanning tree in brief. (1 + 2)
Explain almost complete binary tree with example. (3)
Explain postorder traversal with example.
Explain adjacency matrix representation of a graph. How is it different from incidence matrix representation? (2 + 1)
Explain preorder traversal with example. (3)
Sit a probable paper
A full mock exam built from the most likely questions, mirroring the real paper's structure. Every slot is a real past question.
Most Probable Paper
Mirrors the real structure · 45 marks · based on 5 past papers
- 1.[3 marks]
Explain binary search algorithm with example. (3)
This question has recurred in 2 of 5 years; including the board exam 2× (2078 to 2079); and its topic (Searching and Hashing) appears in 100% of years.
- 2.[3 marks]
Compare linear search with binary search? What are their time complexities? (2 + 1)
This question has recurred in 3 of 5 years; including the board exam 1× (2078); and its topic (Searching and Hashing) appears in 100% of years.
- 3.[3 marks]
Define spanning tree and minimum spanning tree. (1.5 + 1.5)
This question has recurred in 2 of 5 years; including the board exam 1× (2080); and its topic (Trees and Graphs) appears in 80% of years.
- 4.[3 marks]
Explain almost complete binary tree with example. (3)
This question has recurred in 2 of 5 years; including the board exam 1× (2082); and its topic (Trees and Graphs) appears in 80% of years.
- 5.[3 marks]
What is hashing? Explain open hashing. (1 + 2)
This question has recurred in 2 of 5 years; including the board exam 1× (2078); and its topic (Searching and Hashing) appears in 100% of years.
- 1.[6 marks]
What is AVL tree. Construct AVL tree for the sequence 21, 26, 30, 9, 4, 14, 28, and 18. (1 + 5)
This question has recurred in 3 of 5 years; including the board exam 3× (2080 to 2082); and its topic (Trees and Graphs) appears in 80% of years.
- 2.[6 marks]
How do you insert and remove nodes in a singly linked list? (6)
This question has recurred in 3 of 5 years; including the board exam 1× (2082); and its topic (Lists) appears in 100% of years.
- 3.[6 marks]
Explain tail recursion with suitable program. (6)
This question has recurred in 3 of 5 years; including the board exam 1× (2079); and its topic (Recursion) appears in 100% of years.
- 4.[6 marks]
Explain algorithm for converting an infix expression to postfix using stack. Use this algorithm to convert to postfix. (4 + 2)
OR
List some applications of stack. Explain algorithm for evaluating a postfix expression using stack with suitable example. (1.5 + 4.5)
This question has recurred in 2 of 5 years; including the board exam 1× (2080); and its topic (Stack) appears in 100% of years.
- 5.[6 marks]
What is header node in linked list? Explain circular linked list with example. (2 + 4)
This question has recurred in 2 of 5 years; including the board exam 1× (2078); and its topic (Lists) appears in 100% of years.
Behind the numbers
The raw evidence the predictions are computed from: marks per unit per year, syllabus weights, trends, and coverage.
Show the heatmap, topic table and coverage analysis
The receipt: marks per unit, per year
Each row is a syllabus unit, each column an exam year, each cell the marks that unit earned that year. Click any cell to see the actual questions behind it.
| # | Syllabus unit | Probability | Appeared | Avg marks | Syllabus weight | Exam vs syllabus | Trend | Questions |
|---|---|---|---|---|---|---|---|---|
| 1 | U8Trees and Graphs | Very likely80% | 4.8 | 17%8 lecture hrs | Balancedexam 17% · syllabus 17% | Rising | 1 recurring10 total | |
| 2 | U5Lists | Very likely100% | 4.8 | 17%8 lecture hrs | Balancedexam 16% · syllabus 17% | Steady | none repeat10 total | |
| 3 | U7Searching and Hashing | Very likely100% | 4.2 | 15%7 lecture hrs | Balancedexam 13% · syllabus 15% | Steady | 1 recurring9 total | |
| 4 | U6Sorting | Very likely80% | 5.4 | 17%8 lecture hrs | Under-examinedexam 9% · syllabus 17% | Rising | none repeat5 total | |
| 5 | U2Stack | Very likely80% | 5.3 | 12%6 lecture hrs | Balancedexam 16% · syllabus 12% | Fading | none repeat4 total | |
| 6 | U3Queue | Very likely60% | 4 | 8%4 lecture hrs | Balancedexam 10% · syllabus 8% | Steady | none repeat3 total | |
| 7 | U1Introduction to Data Structures & Algorithms | Very likely80% | 3 | 6%3 lecture hrs | Balancedexam 9% · syllabus 6% | Fading | none repeat4 total | |
| 8 | U4Recursion | Very likely40% | 3 | 8%4 lecture hrs | Balancedexam 10% · syllabus 8% | Fading | none repeat2 total |
Study smart, not hard
Drag the slider: studying the top 6 units in priority order covers ~82% of all observed marks.
- ~80% line
Lecture time vs exam marks
Where the exam pays more than the curriculum spends: ● lectures vs ● exam marks, as a share of the whole course. A long teal-leading bar = high-yield unit.
2082 B.S.
2 papers2081 B.S.
4 papersData Structures and Algorithms
board
- 45
- marks
- 120
- min
- 10
- questions
Data Structures and Algorithms
fa
- 45
- marks
- 120
- min
- 10
- questions
Data Structures and Algorithms
sa
- 45
- marks
- 120
- min
- 10
- questions
Data Structures and Algorithms
first-assessment
- 45
- marks
- 120
- min
- 10
- questions