Embercode
✕
Linked ListsQuick quiz

Mixed review of lists

8 questions. Covers Reverse in groups of k in Python.

Questions 1 to 5 of 8

  1. 1. Two lists are built separately with from_list(1, 2) and from_list(1, 2). Both print 1 -> 2. Why does length_difference return None for them?
  2. 2. Put the steps of the length-difference intersection method in the order they run.

    Use the arrows to put the steps in order.

    1. 1.Move the head of the longer list forward by the difference in lengths.
    2. 2.Walk both pointers forward one node at a time.
    3. 3.Stop at the first node where the two pointers are the same object, and return it.
    4. 4.Count the nodes in each list.
  3. 3. What does this code print? ``python head = from_values(1, 2, 3, 4, 5, 6) print(to_list(rotate_right(head, 8))) ` Use rotate_right, from_values and to_list from the rotation lesson, with k` set to 8.
  4. 4. In reverse_in_groups, why does prev start at group_next instead of None?
  5. 5. In the two-pointer intersection method, why does pa become b when pa is None, as in pa = b if pa is None else pa.next?

4 question(s) left on this page.