DAA Assignment_Unit_3_tut _1 (1)
DAA Assignment_Unit_3_tut _1 (1)
1. [CO3]- Define the terms 'in-degree' and 'out-degree' in the context of directed graphs. How are these measures
used in practical applications? [2 marks]
2. [CO3]- If a graph has 10 vertices and a total of 15 edges, what is the minimum number of edges that must be
removed to obtain a spanning tree? [2 marks]
3. [CO3]- Given a text string of length 100 characters and a pattern of length 5 characters, how many
character comparisons would be needed in the worst case for the brute-force string matching algorithm
to find all occurrences of the pattern in the text? [2 marks]
4. [CO3]- What is the hash value of the pattern 'ABCD' using a simple hash function, where 'A' represents 1, 'B'
represents 2, 'C' represents 3, and 'D' represents 4. [2 marks]
5. [CO3]- What is the primary objective of the Knuth-Morris-Pratt (KMP) algorithm, and how
does it achieve this? [2 marks]
Sec-B
/* Note: Each question may have one or two parts */ (3x7=21 marks)
6. [CO3]- Describe the concept of an "adjacency list" in the context of graph representation. Explain how
an adjacency list is used to represent a graph and discuss the advantages and disadvantages of using
adjacency lists compared to other graph representation methods. Provide an example scenario where
using an adjacency list is particularly beneficial. [7 marks]
7. [CO3]- Given a text string "ABCDCBAABDCBAA" and a pattern "AB," find and list all occurrences
of the pattern using the naive string-matching algorithm. Provide the positions of the occurrences
within the text. [7 marks]
8. [CO3]- Explain the concept of the Rabin-Karp string matching algorithm and its primary use. Given a
text "ABCDABCDABCD" and a pattern "ABC," calculate the hash value of the pattern and determine
the positions of pattern occurrences using the Rabin-Karp algorithm. [7 marks]
Sec-C
/* Note: Each question may have one, two, or three parts */ [3*11=33 marks]
9. [CO3]
(a)- Explain the key principles of the finite automata string matching algorithm, including its main
components, and discuss the strengths and limitations of finite automata for string matching
compared to other algorithms. [5 marks]
(b)- Using the provided finite automaton, find all occurrences of the pattern "ABAB" in the text
"ABABABABBABABABA" and show the state transitions. Describe how the finite automaton
processes the text to detect the pattern, including state transitions and the final state it reaches.
[6 marks]
10. [CO3]
(a)- Explain the key principles of the Knuth-Morris-Pratt (KMP) string matching algorithm,
including its preprocessing phase and pattern matching phase. Provide a step-by-step explanation of
how the algorithm works and its time complexity. [5 marks]
(b)- Perform the preprocessing step for the pattern "ABAB" and calculate the partial match table.
Then, use the calculated table to apply the KMP algorithm and find all occurrences of the pattern
"ABAB" in the text "ABABABABBABABABA." Show the positions and state transitions
for each occurrence. [6 marks]
11. [CO3]
(a)-Explain the key principles of Breadth-First Search (BFS) and Depth-First Search (DFS) in graph
traversal. Discuss the fundamental differences between these two algorithms, and provide a real-
world scenario where choosing one algorithm over the other is more advantageous. [5 marks]
(b)- Explain the key principles of the Boyer-Moore string matching algorithm, including its
components and advantages compared to naive string matching. Given a text "ABCDABCDABCD"
and a pattern "ABC", Calculate the number of character comparisons made by Boyer-Moore when
finding the pattern. [6 marks]