Блог пользователя dreamplay

Автор dreamplay, 11 лет назад, По-английски

http://www.spoj.com/SPOJ/problems/ABCPATH/

Consider the above problem which can possibly have a maximum of 2500 letters.

It is a dp on graphs problem,solvable by dfs.

But I had this doubt

Let us consider using say ** dfs only** and not using any sort of DP. What is then the worst case time complexity of the dfs-solution. Expressed in terms of number of steps/letters traversed on the graph.

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
11 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Solution with only dfs will work in O(h2·w2) time. Simple memorization will speed up it to O(h·w).

  • »
    »
    11 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится
    • I understood with Memoization ,it would take O(h.w) steps.

    • How do you claim the only dfs complexity=O(h^2w^2)??Note that maximum path length=26=max(h)/2=max(w/2)

    • Like if there are 2 paths A1-B1-C-D-E and A2-B2-C-D-E ,(A1,A2 are As at different places)

    traversing them by memoization would be (2)+(2)+(3) = 7 steps

    whereas in case of ONLY DFS it would be (5)+(5) = 10 steps.

    So How do You Find a tight bound on maximum number of steps without DP.

    -Thanks