Data Structures & AlgorithmsVery hardGATE CS · TCS NQT

The 3-row by 4-column matrix is filled row by row with 1 to 12. What is the 7th element when the matrix is read in clockwise spiral order starting at the top-left corner?

  1. A. 12
  2. B. 10
  3. C. 11
  4. D. 14

Correct answer: C. 11

Read the outer boundary clockwise (1, 2, 3, 4, 8, 12, 11, 10, 9, 5, 6, 7), then the inner row. The seventh element is 11, which differs from the row-major order.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic