← Quiz: Matrix Traversal: all 13 questions
Quiz: Matrix Traversal · Question 8 of 13
In the spiral code, what goes wrong without the if top <= bottom check on a 1 × 3 matrix [[1, 2, 3]]?
In the spiral code, what goes wrong without the if top <= bottom check on a 1 × 3 matrix [[1, 2, 3]]?
- A.Nothing changes
- B.The single row is printed again backwards: 1 2 3 2 1
- C.It prints an empty list
- D.It loops forever
Answer & explanation
Correct answer: The single row is printed again backwards: 1 2 3 2 1
After the top row is printed, top > bottom; without the check the "bottom row, right to left" step prints it again.
Can you get the rest right without peeking?
Take the timed Quiz: Matrix Traversal quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →