← 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?
- A.Copies are faster
- B.path keeps changing; without a copy every result points to the same list
- C.The results list only accepts copies
- 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 →