Question

Consider the following Graph:

Image ignouacademy-com--p-graph-43196

Figure 1: Graph for Problem 3(a) and 3(b)

a) Write the Kruskal’s algorithm and Prim’s algorithm to find the minimum cost
spanning tree of the graph given in Figure 1. Show all the steps of computation.
Also, compute the time complexity of both the algorithms.
b) In the Figure 1, find the shortest path from the vertex ‘a’ using Dijkstra’s shortest
path algorithm. Show all the steps of computation. Also, find the time complexity
of the algorithm.
c) What is dynamic programming? What is the principle of Optimality? Use the
dynamic programming approach to find the optimal sequence of chain
multiplication of the following matrices:

Matrix Dimension
A1 5 x 10
A2 10 x 20
A3 20 x 15
A4 15 x 8
A5 8 x 10

d) Make all the possible Binary Search Trees for the key values 25, 50, 75.
e) Explain the Knuth Morris Pratt algorithm for string matching. Use this algorithm
to find a pattern “algo” in the Text “From algae to algorithms”. Show all the steps.
What is the time complexity of this algorithm

25 Jul 2024
Answer :
Word Count : 1061

Sure, let’s break down each part of your question step-by-step.

### a) Minimum Cost Spanning Tree Algorithms: Kruskal’s and Prim’s

#### Kruskal’s Algorithm:

Kruskal’s algorithm builds the Minimum Spanning Tree (MST) by adding edges one by one in increasing order of weight, ensuring no cycles are formed. 

Steps:
1. Sort all edges in the graph in non-decreasing order of their weights.
2. Initialize an empty forest, where each node is a separate tree.
3. Add edges to the forest by picking the smallest edge. Only add an edge if it doesn’t form a cycle with the already chosen edges. To check this, use a Union-Find data structure.

Example:
1. Sort edges: (A, B, 1), (B, C, 2), (C, D, 3), (A, C, 4), (B, D, 5)
2. Initialize empty forest.
3. Add edges:
   - (A, B, 1) → MST: {(A, B, 1)}
   - (B, C, 2) → MST: {(A, B, 1), (B, C, 2)}
   - (C, D, 3) → MST: {(A, B, 1), (B, C, 2), (C, D, 3)}
   - Adding (A, C, 4) would form a cycle, so skip it.
   - Adding (B, D, 5) would form a cycle, so skip it.

MST Edges:
- {(A, B, 1), (B, C, 2), (C, D, 3)}

Time Complexity:
- Sorting edges: \(O(E \log E)\)
- Union-Find operations: \(O(E \log V)\)
- Overall: \(O(E \log E)\) (since \(E \log E\) dominates \(E \log V\))

#### Prim’s Algorithm:

Prim’s algorithm starts from a single vertex and grows the MST by adding the smallest edge that connects a vertex in the MST to a vertex outside the MST.

Steps:
1. Start with a single vertex and initialize the MST as empty.
2. Grow the MST by adding the minimum weight edge that connects a vertex in the MST to a vertex outside the MST.
3. Repeat until all vertices are included.

Example:
1. Start at vertex A. Add edges to MST:
   - Minimum edge: (A, B, 1)
2. Add B, update edge list:
   - Minimum edge from {A, B}: (B, C, 2)
3. Add C, update edge list:
   - Minimum edge from {A, B, C}: (C, D, 3)
4. Add D. MST is complete.

MST Edges:
- {(A, B, 1), (B, C, 2), (C, D, 3)}

Time Complexity:
- Using a priority queue: \(O(E \log V)\)
- Overall: \(O(E \log V)\)

###

___ _______ __________ ___ ___ _______ _____.
___ _____ ___ _____ ________ ___ __________ _______ __________ _____ ____ __________.
_________ ____ ____ _______ __________ __________ __________ ___.
___ ___ _____ _________ ________ _____ __________ _______ _____ _____.
________ ____ __________ __________ __________ _______ __________ ____.
_____ __________ __________ ___ ________ ___ _______ _______ ________ ____ _____ ___.
____ ____ __________ ___ _____ _________ _______ ____ ________.
_________ _________ _____ _________ __________ ________ ___.
_________ ______ ______ _______ ________ ______ _________ _________ ______ _________ _______.
________ ______ __________ ____ _____.
_____ __________ _________ ______ ____ __________ __________ __________ ___.
____ ____ __________ ________ __________ ____ _______ ______ ________.
____ _____ ______ _____ ________ ______.
____ ________ ______ __________ ____ _______ _________ ____ ____ __________ ______ _______.
___ _________ _____ ________ ________ ________.
___ _____ _________ _____ ___ ______ _________ __________ ________ ________.
________ _____ ________ ___ _________ ___ _____ __________.
________ ______ _____ ____ ____ _________ _________ ______ ______.
____ _______ _________ ___ ________ ____ ____ ___ ______ ______ _____ ____.
____ _______ _______ ________ ______ ___ ________.
________ ________ __________ __________ ________.
__________ __________ _______ _________ _________ ___ _________ ________ ___ ________ __________.
______ ________ __________ ________ _____ _____ _____ __________ _______ ________ _______ __________.
______ _______ _____ _____ ______.
________ ____ _________ _____ _________.
___ ___ ______ ____ _____ ______ _______ ____.
_____ ______ ____ ________ ____ ___ ___ ____.
_____ ___ ___ ________ _________ __________ ______ _________ _______ ____ _______ _____.
__________ ____ ____ ___ ______ _____ _________ _______ _________ ______ ______.
_______ ______ _____ ________ ______ ________ __________ ________ ____ ________.
__________ _______ _________ _______ ____ ______ __________ _________.
_____ _______ ___ ________ ________ ___ ______ _______.
___ ______ __________ _________ ____ ________ ______ ______ _______ ___ _____.
_______ ____ _________ _____ _______ __________.
___ __________ _________ ____ ___.
__________ ________ _______ ______ ________ ____ _________ _______ _______ _________ __________ ______.
_______ ____ __________ _______ __________.
___ ____ _____ ________ ________.
____ ____ ______ _____ ___ ______ __________ ___ ____.
__________ ______ __________ __________ ___ ________ ___ ______.
________ ________ ___ _________ ___ _________ _________ ______.
________ ___ __________ ______ _____ _______ ___ ___ ________ ____ ______.
______ _______ ___ ___ _____ ________.
________ _______ ___ ___ ___ _______ _________ _________.
_________ _____ ________ _________ ____ ___.
______ __________ ___ _________ ________ _____ ________ ____.
__________ ________ _____ ___ ________ _______ ____ ____ ________.
________ ________ __________ ______ _______ ______.
_______ _______ _______ ________ __________ ____ _________ __________ ___ ___ _______.
____ _________ ________ _________ ___ ____ ________ _____ ________ ______.
___ __________ ___ _____ _________ ______ __________ ________.
______ _____ _____ ____ ________ ___.
___ _____ ______ ____ _____ ________ _______ _______ ___ ______ ____ ______.
_________ __________ ____ ______ __________ ______ _______ _____ _____ ____ ____.
____ __________ _________ ___ ______ ____.
____ ________ ______ ____ _____ _______.
__________ __________ ____ __________ ______ ________ ___ _________ _______.
__________ ________ _________ ________ __________ _______ ___ ____ ______.
__________ ______ _____ __________ _______.
____ _______ _____ _____ __________ ______ _______ _______.
________ __________ ___ ___ _______ ___ ________ _______.
____ __________ ______ ___ _____ _______ ____ ____ _____.
______ ____ ___ __________ _____ ______ ________ ______ ____ ____.
_____ ___ _____ ____ ________ ______ ___ ___.
________ ________ ___ ______ ________ ___ _______.
__________ ______ _________ ______ __________ __________ ___.
______ ____ _________ _________ __________ ____ ___ ________ __________.
_____ _______ ________ _________ _____ ____ ________ _______ __________ ______ ___ _________.
__________ ____ _____ ________ ______ _______ _____ _____.
__________ ___ _____ ____ _________ ____ ____ __________ ________ ____.
_______ _______ ____ __________ ________.
__________ ______ ________ _____ _________ ______ ____ ______ ________.
_________ ______ _______ ________ ______ ____.
_________ _________ _________ ____ __________ ______.
________ _________ ________ __________ ____ _________ _____.
______ _____ ________ ________ _____ _________ __________.
_______ _______ ____ _____ __________.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU MCS 211 2024 - Consider the following Graph:Figure 1: Graph for Problem 3(a) | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→