Assignment
Subject: DSA -→ UNIT-3
TREES ASSIGNMENT QUESTIONS (C++)
Basic Tree Concepts
1. Define and explain the following terms with diagrams: root, leaf,
internal node, degree, level, height, sibling.
2. Write a C++ program to represent a binary tree using structures and
pointers.
Binary Tree Operations & Traversals
3. Implement inorder, preorder, and postorder tree traversals using both
recursion and iteration.
4. Write a program to count the number of leaf nodes, non-leaf nodes,
and total nodes in a binary tree.
5. Implement a function to find the height/depth of a binary tree.
6. Write a program to copy a binary tree into another binary tree.
7. Implement a function to mirror a binary tree.
Types & Applications of Trees
8. Write a program to check if a binary tree is complete or perfect.
9. Explain and implement a Threaded Binary Tree.
10.Write a program to convert an expression into an expression tree and
evaluate it.
BINARY SEARCH TREES (BST), AVL, B-TREES
Binary Search Tree (BST)
11.Implement a Binary Search Tree with insertion, deletion, and search
operations.
12.Write a program to find the inorder successor and predecessor of a
node in BST.
13.Write a program to delete a node in BST (handle all 3 cases).
AVL Trees
14.Implement an AVL Tree with insertion operation and display all
rotations.
Assignment
15.Write a function to check whether a given binary tree is height-
balanced.
B-Tree and B+ Tree
16.Write a program to implement insertion and search operation in a B-
Tree (order 3).
17.Write a short note and diagrammatically explain how B+ Trees differ
from B-Trees.
GRAPHS ASSIGNMENT QUESTIONS (C++)
Basic Graphs Concepts
18.Explain with example: adjacency matrix and adjacency list. Implement
both using C++.
19.Implement a graph and perform DFS and BFS traversals (using
recursion or stack/queue).
Graph Applications
20.Implement Dijkstra’s Algorithm to find the shortest path from a source
node.
21.Implement Topological Sorting using Kahn’s Algorithm or DFS.
22.Implement Prim's and Kruskal’s Algorithm for Minimum Spanning Tree.
***THE END***