Discrete Structure · Unit 9
Trees and Graph Algorithms
Exam-focused notes for Trees and Graph Algorithms (Discrete Structure, BIT152): what the TU syllabus asks and how it has actually been tested, with 14 solved past questions from this unit.
What this unit covers
- Tree definition and properties
- Spanning trees
- Minimum spanning trees
- Kruskal's algorithm
- Tree traversal methods
- Pre-order traversal
- In-order traversal
- Post-order traversal
- Euler paths and circuits
- Hamilton paths and circuits
- Cut vertices and cut edges
- Dijkstra's algorithm for shortest paths
Euler paths and circuits
Mention the necessary and sufficient conditions for Euler path and Euler circuit with example. [5]
- Euler Path: A path in a graph that visits every edge exactly once. - Euler Circuit: A closed path (circuit) in a graph that visits every edge exactly once and starts and ends at the same vertex. --- A connected graph G has an Euler Path if and only if it ...
Full solved answer →State necessary and sufficient conditions for a graph to have Euler path and circuit.Find the GCD of 12 and 18 using Extended Euclidian Algorithm.[4+6]
- Numbers for GCD computation: $a = 12$, $b = 18$ - Required: necessary and sufficient conditions for Euler path and Euler circuit; GCD via Extended Euclidean Algorithm expressing $\gcd$ as a linear combination. No data missing. --- - Euler Path: A trail th...
Full solved answer →What is Euler path? Compare it with Hamilton path. [5]
An Euler path (also called an Eulerian path) is a path in a graph that visits every edge exactly once. If such a path starts and ends at the same vertex, it is called an Euler circuit (or Eulerian circuit). - A connected graph has an Euler path if and only ...
Full solved answer →Dijkstra's algorithm for shortest paths
Find the shortest path from a to z in following graph using Dijkstra’s algorithm. [5]
Problem: Find shortest path from $a$ to $z$ using Dijkstra's algorithm. Critical issue: The question refers to a graph ("following graph"), but no graph image, edge list, or weight data is provided in the text supplied to me. Dijkstra's algorithm requires: ...
Full solved answer →Write the Dijkstra's algorithm to find the shortest path between two nodes in graph. [5]
Dijkstra's algorithm is a greedy algorithm that finds the shortest path from a source node to all other nodes (or a specific destination node) in a weighted graph with non-negative edge weights. --- --- --- Consider the graph: Find shortest path from A to E...
Full solved answer →Write Dijkstra’s algorithm to find the shortest path from source node to goal node. [5]
Dijkstra's algorithm finds the shortest path from a source node to all other nodes (or a specific goal node) in a weighted graph with non-negative edge weights. --- - dist[] : array storing shortest distance from source to each node - visited[] : boolean ar...
Full solved answer →What is shortest path finding problem? Use Dijkstra's algorithm to find the length of the shortest path between a and z in the given weighted graphs.[10]
- Algorithm required: Dijkstra's algorithm - Source vertex: $a$ - Destination vertex: $z$ - Graph: "the given weighted graph" - the actual graph image/edge weights are NOT provided in the question text. Missing data: The specific weighted graph (vertices, e...
Full solved answer →Tree definition and properties
Define spanning and minimum spanning tree? How do you traverse tree? [2+3]
A spanning tree of a connected, undirected graph G = (V, E) is a subgraph that: - Includes all the vertices of the graph - Is a tree (connected and acyclic) - Has exactly V - 1 edges A graph with n vertices will have a spanning tree with exactly n - 1 edges...
Full solved answer →Cut vertices and cut edges
Define cut vertices and cut edges. How do you determine whether the graph has Euler path? [5]
A cut vertex (or articulation point) of a connected graph G is a vertex whose removal (along with all edges incident to it) increases the number of connected components of the graph. In other words, vertex v is a cut vertex if G is connected but G - v is di...
Full solved answer →Tree traversal methods
Describe pre-order, postorder and inorder traversal of a tree with an example. [5]
Tree traversal means visiting every node of a tree exactly once in a systematic way. The three standard depth-first traversal methods differ in when the root (parent) node is visited relative to its subtrees. --- --- Algorithm: 1. Visit the root node 2. Rec...
Full solved answer →Pre-order traversal
Define tree traversal. Explain pre-order traversal with example. [5]
Tree traversal is the process of visiting each node in a tree data structure exactly once in a systematic and well-defined order. It is used to process, search, or display all the nodes of a tree. Unlike linear data structures (arrays, linked lists), trees ...
Full solved answer →Minimum spanning trees
Define spanning tree and minimum spanning tree with suitable example. Use Kruskal's algorithms to find minimum spanning tree in the given graph[10]
The question refers to "the given graph," but no graph (vertices, edges and weights) is reproduced with the question text available here. The working below therefore uses the standard 9-vertex textbook MST example so that the method is demonstrated in full....
Full solved answer →Kruskal's algorithm
How does Kruskal algorithm work? Illustrate with an example. [5]
Kruskal's algorithm is a greedy algorithm used to find the Minimum Spanning Tree (MST) of a connected, undirected, weighted graph. It builds the MST by always picking the smallest available edge that does not form a cycle. --- 1. Sort all edges in non-decre...
Full solved answer →Spanning trees
Define spanning tree. Explain minimum spanning tree with example. [5]
A spanning tree of a connected, undirected graph G = (V, E) is a subgraph that: - Includes all vertices of the graph - Is a tree (connected and acyclic) - Has exactly V - 1 edges A graph with n vertices will have a spanning tree with exactly n - 1 edges. --...
Full solved answer →Make Unit 9 stick
Practice BIT152 with flashcards & quizzes