Right-and-down paths across a 6x6 grid and N by M
Question
A game character occupies the top-left square of a grid and may only step right or down.
(a) How many routes take it to the bottom-right square ?
(b) Describe an algorithm that counts such routes on a general grid.
Short answer
(a) . Every route uses exactly right and down steps, so it is fixed by choosing which of the steps go right: . (b) Either return directly, or fill a DP table with and ones along the first row and column, which is time and memory with a rolling row.
Adapted from OpenQuant; question and answer rewritten by SelfMadeQuant.com.
See the hint and the full worked solution in the question bank (free account).
Open the worked solutionLessons behind this question
- Counting and Combinatorics
- Algorithms, Growth Rates, and Asymptotic Notation
- Quicksort and Randomized Quicksort
Start with a free lesson: Probability Fundamentals is part of a free topic. Create a free account, no card needed, to read it in full with worked solutions.
Read it free