Midsem_Level_Tree_AVL_Questions_with_Answers
Midsem_Level_Tree_AVL_Questions_with_Answers
Q1. Q1.a) Calculate the time complexity for inserting n nodes in a Binary Search Tree (BST) in the b
Ans: a) In BST:
Q2. Q2.Write a recursive function to count the total number of nodes in a binary tree.Explain how th
Ans: Function:
Explanation:
The call stack stores recursive calls until base cases are hit, and then combines results on backtracking.
Q3. Q3 a.Perform In-order, Pre-order, and Post-order traversal of the following binary tree: A
Ans: In-order: D B E A C
Pre-order: A B D E C
Post-order: D E B C A
Q4. Q3 b.Represent the above tree using:i) Array Representation (index starts from 1)ii) Linked List
Tree & AVL Tree Practice Questions with Solutions
struct Node {
char data;
Node* left;
Node* right;
};
Q5. Q4 a.Compare AVL Tree vs Binary Search Tree:Balance factorTime complexity (Search, Insert, D
- Height: log n
BST:
- Worst-case O(n)
Applications of AVL:
2. Memory management in OS
Q6. Q4 b.Construct an AVL Tree by inserting the keys:30, 20, 10, 25, 40, 50Draw tree after each inse
Tree: 20
/ \
10 30
Final Tree:
20
/ \
10 30
/\
25 40
50