Assignment 2
Assignment 2
8. Apply Kruskal/Prim's algorithms to find the minimum spanning tree of the following graph.
9. Solve the following instance of the single source shortest path problem with vertex a as the source.
10. Find all solutions to 4-Queens and 8-Queens problem. Explain the process of backtracking in finding the solutions. 11. Draw a RB tree from the following set of elements: (23, 12, 24, 33, 2, 5, 6, 7, 43, 16) 12. Delete the element 24 from the above RB tree, and draw the tree after the deletion. 13. Insert 54 and 58 to the RB tree in question 28 and draw the respective RB trees. 14. Explain the Binomial/Fibonacci heap operations. 15. Show the comparisons the naive string matcher makes for the pattern P = 0001 in the text 16. T = 000010001010001. 17. Compute the prefix function for the pattern ababbabbabbababbabb when the alphabet is = {a, b}. 18. Write an algorithm to find the GCD and LCM of two integers a and b. What are the time complexities of your algorithm. 19. What is an optimal Huffman code for the following set of frequencies, based on the first 8 Fibonacci numbers? a:1 b:1 c:2 d:3 e:5 f:8 g:13 h:21 20. Construct the string-matching automaton for the pattern P = aabab and illustrate its operation on the text string T = aaababaabaababaab. 21. Working modulo q = 11, how many spurious hits does the Rabin-Karp matcher encounter in the text T = 3141592653589793 when looking for the pattern P = 26? ++++++++++++++++++