Assignment 3-W01.
100 Points. Due
10/10
No questions below require coding. All questions must be solved by hand and legible before
turning it.
1) Given the pattern P and the text T below, apply KMP algorithm. Show the total comparison
before a match and show the longest prefix table used to solve it. Show all tables applied
P = ABCABC
T = ABABDABACDABABCABCB.
2) Sort the array [7, 2, -1, 6, 8, 0, 3, 4] using Quick Sort. Use the last element as the pivot in each
recursive call. Count the number of comparisons and the total number of auxiliary arrays used.
Show all the steps from start to finish and show the sorted list.
3) Apply Divide and Conquer, solve by hand and show all steps: 70546345 * 24456, identify A1, A2,
B1 , B 2
Show all the steps and computations, explain how your solution may have improved time
efficiency than the regular integer multiplication process.
4) Apply Divide and Conquer technique to find the closest pair or pairs in a 2D coordinate
plane of points.
P = {(0, 3), (1, 1), (2, 2), (4, 4), (0, 0), (1, 2), (3, 1), (3, 3)}
Show all the steps and computations, explain how your solution may have improved time
efficiency than the brute force approach.
Notes:
Students should work independently. Each student is responsible for handing in an original work.