Dynamic Programming Algorithm: Walking the Grid

I was given some practical questions for the upcoming exam. I have already been given a solution to this problem, described in this picture here enter image description here

In fact, there is no explanation for this decision.

I am curious how I can come to an answer here. I suppose I can create a bunch of subtasks like

Bypass A-> C, A-> D, A-> E, then print A-> B based on previous solutions. But I was completely lost.

+4
source share
2 answers

-, (0,0) (x, y), R = right U = up ? ( , .) x + y x R y U, binom (x + y, x) binom (x + y, y) .

, , A-B ( nAB), A-C ( nAC), A-D,... .. ( ). : C D ( ) D C, .

. , . , , , . ? nAC x nCB. E, nAE x nEB ... . D . nAD x nDB, B, E... . , (, 2 )... . C E B? nAC x nCE x nEB, . D E? nAD x nDE x nEB, . , , .

+5

, , . . , ( ) - . ASCII:

1 -> 1 -> 7 -> 7 ->14
^         ^         ^
|         |         |
1    C    6    E    7
^         ^         ^
|         |         |
1 -> 3 -> 6 -> 6 -> 7
^    ^    ^         ^
|    |    |         |
1 -> 2 -> 3    D    1
^    ^    ^         ^
|    |    |         |
A -> 1 -> 1 -> 1 -> 1

, , . , . - , . , , - , - 1:

0 -> 
          ^         ^
          |         |
0 ->      0 ->      0 ->


0 -> 
                    ^
                    |
0 ->                0 ->
     ^
     |
     1 ->
          ^    ^    ^    ^
          |    |    |    |
          0    0    0    0  

, , A B :

0 -> 1 -> 1 -> 7 -> 7 ->14
     ^    ^    ^    ^    ^
     |    |    |    |    |
0 -> 1    0 -> 6    0 -> 7
     ^         ^         ^
     |         |         |
0 -> 1 -> 3 -> 6 -> 6 -> 7
     ^    ^    ^    ^    ^
     |    |    |    |    |
0 -> 1 -> 2 -> 3    0 -> 1
     ^    ^    ^         ^
     |    |    |         |
     1 -> 1 -> 1 -> 1 -> 1
          ^    ^    ^    ^
          |    |    |    |
          0    0    0    0
+3

All Articles