Embercode
✕
Dynamic ProgrammingQuick quiz

Grid paths and triangles

7 questions. Covers Minimum path sum and triangle from the bottom in Python.

Questions 1 to 5 of 7

  1. 1. A 3 by 3 grid has its centre cell blocked. The robot moves only right or down, from the top-left corner to the bottom-right corner. How many routes are there?
  2. 2. In the bottom-up triangle method, why must the inner loop of each row run from left to right?
  3. 3. Which statements about counting routes and the grid table are true? Pick all that apply.

    Pick every answer that is true.

  4. 4. Which statements about the minimum path sum and the triangle are true? Pick all that apply.

    Pick every answer that is true.

  5. 5. What does this program print? ``python def min_total_bottom_up(triangle): rows = len(triangle) best = list(triangle[-1]) for r in range(rows - 2, -1, -1): row = triangle[r] for c in range(len(row)): best[c] = row[c] + min(best[c], best[c + 1]) return best[0] tri = [[5], [9, 2], [1, 7, 3]] print(f"answer = {min_total_bottom_up(tri)}") ``

5 question(s) left on this page.