Embercode
✕
GraphsQuick quiz

Islands II

6 questions. Covers Number of islands II: union-find on a growing grid in Python.

Questions 1 to 5 of 6

  1. 1. Using the num_islands_2 function from this lesson, what does this call print? ``python print(num_islands_2(2, 2, [(0, 0), (1, 1), (0, 1), (1, 0)])) ``
  2. 2. A new land cell touches two land cells that belong to two different islands. The new cell adds one island, and each merge removes one. What is the net change in the island count?
  3. 3. Using the num_islands_2 function from this lesson, what does this call print? ``python print(num_islands_2(1, 4, [(0, 0), (0, 2), (0, 3), (0, 1)])) ``
  4. 4. In a 3 by 3 grid, cells are numbered row by row from 0 with flat index r * cols + c. What is the flat index of cell (2, 1)?
  5. 5. Which statements about the check_islands.py program in this lesson are true?

    Pick every answer that is true.

5 question(s) left on this page.