🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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 →
  1. Q1. What does this print? (code)
  2. Q2. What is the spiral order of [[1, 2, 3], [4, 5, 6], [7, 8, 9]]?
  3. Q3. How do you rotate a square matrix 90° clockwise in place?
  4. Q4. Cells (0, 2), (1, 1) and (2, 0) of a 3×3 matrix all have the same:
  5. Q5. What does this print? (code)
  6. Q6. Why does BFS (not DFS) find the shortest path in an unweighted grid?
  7. Q7. What is the time complexity of printing an R × C matrix in spiral order?
  8. Q8. In the spiral code, what goes wrong without the if top <= bottom check on a 1 × 3 matrix [[1, 2, 3]]?
  9. Q9. What does this print? (code)
  10. Q10. Which key groups cells on the same main diagonal (top-left to bottom-right)?
  11. Q11. What does this print? (code)
  12. Q12. In grid problems, what are direction arrays such as dr = [-1, 1, 0, 0] and dc = [0, 0, -1, 1] for?
  13. Q13. Before reading a neighbour (nr, nc), what must you check?