DAA Assignment - 3 - Tut - 2
DAA Assignment - 3 - Tut - 2
1. [CO3]- What is a "spanning tree" of a graph, and why is it important in the study of graphs? [2 marks]
2. [CO3]- How can an "adjacency matrix" be used to represent a graph, and what are the advantages and
disadvantages of using this representation? [2 marks]
3. [CO3]- Compare and briefly state the time complexity of the following string-matching algorithms: Naive,
Knuth-Morris-Pratt (KMP), Rabin-Karp, Finite Automata, and Boyer-Moore. [2 marks]
4. [CO3]- Explain what a "shortest path" in a graph means and provide an example of a real-world scenario where
finding the shortest path in a graph is useful. [2 marks]
5. [CO3]- Compare and briefly state the time complexity of the following graph algorithms: Prim's algorithm,
Dijkstra's algorithm, the Bellman-Ford algorithm, and Kruskal's algorithm. [2 marks]
Sec-B
/* Note: Each question may have one or two parts */ (3x7=21 marks)
6. [CO3]-what is the Minimum Cost Spanning Tree? Explain Kruskal’s Algorithm and find the MST of
the graph. Also, write its Time-Complexity.
[7 marks]
7. [CO3]- Write the Knuth-Morris-Pratt (KMP) string matching algorithm, and using it, find all occurrences of the
pattern "ABC" in the text "ABCABCWABCABC”. [7 marks]
8. [CO3]- Apply the Boyer-Moore string matching algorithm to find and list all occurrences of the pattern
"XCDY" in the text "XYXCDYXCDYACDXCDY." Show the positions of pattern occurrences and
explain the key components that make Boyer-Moore efficient for this task. [7 marks]
Sec-C
/* Note: Each question may have one, two, or three parts */ [3*11=33 marks]
9. [CO3]
Using the Rabin-Karp algorithm with a random prime number (e.g., 13) for the mod process, find
and list all occurrences of the pattern "31415" in the text "2718281828459043141592653." Show
the positions and steps taken during the search process, and indicate which hits are valid and
which are spurious. [7 marks]
(b)- Explain the key principles of Dijkstra's algorithm for finding the shortest path in a weighted
graph. Highlight the importance of maintaining a priority queue for efficient implementation.
[4 marks]
10. [CO3] -Define the Floyd Warshall Algorithm for all pair shortest paths and apply the same on the
following graph. [11 marks]
11. [CO3]- Given the following graph, apply both Prim's and Kruskal's algorithms to find the minimum
cost-spanning tree in both cases. Provide the steps and final results for each algorithm. [11 marks]