linear inequalities, utilizing Bellman-Ford algorithm by clickmyadspleaseXOXO

VIEWS: 84 PAGES: 2

									ICS311 Hwk Sol Chs. 24, 32
Ch.24 1. Find the feasible solution to the following system of linear inequalities, utilizing Bellman-Ford algorithm. Use alphabetical ordering. x1 – x3<= -1 x3– x2 <= 5 x3 – x4 <= -2 x4 – x1 <= -4 x2 – x1 <= 1 x1 – x4 <= -5 Convert to a graph, add extra node v0. The graph has edges and weights: 01 02 03 04 12 14 23 31 41 43 0 0 0 0 1 -4 5 -1 -5 -2 V1 v2 v3 v4 I=1 0,\ 0,\ 0,\ 0,\ -1,v3 -4, v1 -9,v4 -6,v4 I=2 -18,v4 -8,v1 -15,v4 -13,v1 I=3 … the keys for v1 and v4 will keep on increasing, because they are in a negative cycle I=4 So, there is no feasible solution. Ch.32 1. Trace searching for pattern P = 77 using Rabin-Karp algorithm on the text T = 05337752266533377755. Use q=11 and d=10. How many spurious hits does the algorithm encounter? 05337752266533377755 Yellow ones are spurious hits. There are 6 of them. 5 3 0 4 0 9 8 0 4 0 10 9 0 0 4

0 0 9 0 2. Construct the string-matching automaton and draw its state transition diagram for pattern P = abaaba. Illustrate its operation on the text string T = aaabaababaabaaba.

To do this question, the best method that I found so far is to have the pattern and the string written on two pieces of paper, and then slide the papers over each other. b a 2 a a For the loop-back version with 5 states: (alternately, we can have go-n-stop machine, with 6 states, where from state 5 input=a takes us to state 6). 3 a 4 b 5

a a 0 1 b

1. End state
Initial state 0 1 2 3 4 5 Input=a 1 1 3 4 1 3 Input=b 0 2 0 2 5 0


								
To top