Skip to content

Latest commit

 

History

History
36 lines (27 loc) · 993 Bytes

collections-mystery-answers.md

File metadata and controls

36 lines (27 loc) · 993 Bytes

CSE 143

Collections Mystery Answers

Final Study Session

  1. Collections Mystery.

    Method Call Contents of Set Returned
    mystery(grid, 2, 2) [6, 7]
    mystery(grid, 0, 2) [1, 2, 5, 8]
    mystery(grid, 3, 3) [1, 2, 3, 7, 9]
  2. Collections Mystery.

    Map Output
    [["a", "b"], ["c", "d", "e"], ["f"]] {a=0, b=1, c=0, d=1, e=2, f=0}
    [["y", "a", "y"], ["b", "r", "e", "a", "k"]] {a=3, b=0, e=2, k=4, r=1, y=2}
    [["n", "e", "v", "e", "r"], ["o", "d", "d"], ["o", "r"], ["e", "v", "e", "n"]] {d=2, e=2, n=3, o=0, r=1, v=1}
  3. Collections Mystery.

    Method Call Value Returned
    mystery(grid, 5); 5
    mystery(grid, 3); 22
    mystery(grid, 1); 24
  4. Collections Mystery.

    Method Call Output Produced
    mystery(grid, 0, 2, 2); 10 11
    mystery(grid, 2, 3, 2); 12 9 12
    mystery(grid, 1, 4, 1); 4 8 2 3