Embercode
✕
Dynamic ProgrammingQuick quiz

Egg drop and DAG DP

8 questions. Covers Longest path in a DAG by topological DP in Python.

Questions 1 to 5 of 8

  1. 1. Put the steps of Kahn's algorithm in the order the lesson gives them.

    Use the arrows to put the steps in order.

    1. 1.Take a vertex from the front of the queue, add it to the order, and lower the in-degree of each vertex it points to
    2. 2.Stop when the queue is empty, then check that the order holds every vertex
    3. 3.Put every vertex with in-degree 0 into a queue
    4. 4.Count the in-degree of every vertex
  2. 2. What does this program print? ``python reach = [[0] * 3 for _ in range(5)] for m in range(1, 5): for e in range(1, 3): reach[m][e] = reach[m - 1][e - 1] + reach[m - 1][e] + 1 print(reach[3][2], reach[4][2]) ``
  3. 3. In the moves table reach[m][e], what does the value mean?
  4. 4. Match each term from the lessons to its meaning.

    Choose the matching item for each row.

  5. 5. What happens when this Python code runs? ``python unknown = None candidate = unknown + -1 print('NONE + -1 =', candidate) ``

4 question(s) left on this page.