🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Recursion & Backtracking Quiz: all 7 questions

Recursion & Backtracking Quiz · Question 5 of 7

Why must you append a COPY of path (path[:] / new ArrayList<(path)) to the results?

Why must you append a COPY of path (path[:] / new ArrayList<>(path)) to the results?

  1. A.Copies are faster
  2. B.path keeps changing; without a copy every result points to the same list
  3. C.The results list only accepts copies
  4. D.To sort the result
Answer & explanation

Correct answer: path keeps changing; without a copy every result points to the same list

By the end, the shared list is empty again — every stored "result" would be empty.

Can you get the rest right without peeking?

Take the timed Recursion & Backtracking Quiz quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →