← All topics
Quiz: Matrix Traversal: questions with answers
13 questions, each with the answer and a short explanation.
Take the timed quiz + get a certificate →- Q1. What does this print? (code)
- Q2. What is the spiral order of [[1, 2, 3], [4, 5, 6], [7, 8, 9]]?
- Q3. How do you rotate a square matrix 90° clockwise in place?
- Q4. Cells (0, 2), (1, 1) and (2, 0) of a 3×3 matrix all have the same:
- Q5. What does this print? (code)
- Q6. Why does BFS (not DFS) find the shortest path in an unweighted grid?
- Q7. What is the time complexity of printing an R × C matrix in spiral order?
- Q8. In the spiral code, what goes wrong without the if top <= bottom check on a 1 × 3 matrix [[1, 2, 3]]?
- Q9. What does this print? (code)
- Q10. Which key groups cells on the same main diagonal (top-left to bottom-right)?
- Q11. What does this print? (code)
- Q12. In grid problems, what are direction arrays such as dr = [-1, 1, 0, 0] and dc = [0, 0, -1, 1] for?
- Q13. Before reading a neighbour (nr, nc), what must you check?