w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Dynamic programming graph algorithm


first (str) return the first letter of str
Let len(str) return the length of str
Let rem(str) return str with the first character stripped off.

func (str, v1) =
    true if
    len(str)=0 and s == f
    func(rem(str), v2) is true for any v2 such that there exists an edge
connecting v1, v2 labeled first(str)

The values of f (str, v) can be memoised to avoid unnecessary recursive calls.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.