Tuesday, 15 July 2014

Dynamic programming graph algorithm -



Dynamic programming graph algorithm -

i learning dynamic programming , can't figure problem out. give me algorithm it? : consider directed graph g = (v,e) each border labeled character alphabet sigma, , designate special vertex s start vertex, , f final vertex. g accepts string = a1a2 . . . if there path s f of n edges labels spell sequence a. design o((|v | + |e|)n) dynamic programming algorithm determine whether or not accepted g.

let

first (str) homecoming first letter of str allow len(str) homecoming length of str allow rem(str) homecoming str first character stripped off. func (str, v1) = true if len(str)=0 , s == f or func(rem(str), v2) true v2 such there exists border connecting v1, v2 labeled first(str)

the values of f (str, v) can memoised avoid unnecessary recursive calls.

algorithm dynamic-programming directed-graph

No comments:

Post a Comment