Unit summary
- A graph is a set of vertices joined by edges, and may be directed, undirected or weighted.
- Graphs are stored as adjacency matrices or adjacency lists, and traversed by BFS (queue) or DFS (stack).
- A tree is a connected acyclic graph with a root; a binary tree has at most two children per node.
- Binary trees are traversed in preorder, inorder and postorder.
- A binary search tree keeps smaller keys on the left and larger on the right, with O(h) operations.
- AVL trees keep balance factors in −1 to +1 by rotations, giving O(log n) operations.
Glossary
| Term | Meaning |
|---|---|
| Adjacency list | A list of neighbours for each vertex. |
| Adjacency matrix | An n × n matrix of edges. |
| AVL tree | A height-balanced BST. |
| Balance factor | Height of left minus height of right subtree. |
| BFS | Breadth-first search using a queue. |
| Binary search tree | An ordered binary tree. |
| Binary tree | A tree with at most two children per node. |
| Cycle | A path that returns to its start. |
| Degree | The number of edges at a vertex. |
| DFS | Depth-first search using a stack. |
| Edge | A link between two vertices. |
| Graph | Vertices joined by edges. |
| Height | The largest level of a node in a tree. |
| Inorder | Left, root, right traversal. |
| Inorder successor | The smallest key in the right subtree. |
| Leaf | A node with no children. |
| Path | A sequence of vertices joined by edges. |
| Rotation | A pointer change that rebalances a tree. |
| Tree | A connected acyclic graph with a root. |
| Vertex | A node of a graph. |
Question bank
Short Answer Questions (2 marks each)
- Define a graph.
- What is the degree of a vertex?
- What is an adjacency list?
- Distinguish BFS and DFS.
- Define a binary tree.
- What is a leaf node?
- Write the inorder traversal rule.
- Define a binary search tree.
- What is an AVL tree?
- What is a balance factor?
Medium Answer Questions (5 marks each)
- Explain the representation of graphs.
- Explain BFS with an example.
- Explain DFS with an example.
- Explain the traversals of a binary tree with an example.
- Explain deletion in a binary search tree.
- Explain the rotations of an AVL tree.
Long Answer Questions (15 marks each)
- Explain graphs, their terminology and representation, and their traversal by BFS and DFS.
- Explain trees and binary trees, with their terminology and representation.
- Explain the traversals of binary trees and the operations of a binary search tree.
- Explain AVL trees, with insertion and deletion and the four rotations.
Sources
- Official BCA syllabus Data Structures, course code 25BCA402DS02, Unit IV
