When teaching arrays, have students complete the Four Rotations problems in pairs.

  • The exercise is constructed as follows:
    • You have an array that should undergo four rotations: clockwise 90 degrees, counterclockwise 90 degrees, 180 degrees, and reflect your array across the diagonal.
  • Have each pair to brainstorm ways they can accomplish these rotations individually. Then have them share with each other and combine their ideas.
    • What would it look like if I asked you to write a method that only rotates 180 degrees?
  • Students have to really understand row and column rotations, and how arrays are manipulated to successfully complete a diagonal reflection.
    • A common error is students wrote code that only rotates the outside rows and columns, leaving all the inner cells unaltered.
  • One of the great parts of this exercise is it’s really easy for students to see if their code is working or not.
  • This exercise has a strong math connection, you could use it in an Advanced Math class.
    • For an additional challenge have students write a matrix multiplication program.
  • Completing this exercise helps students learn matrix multiplication when they come across this material in a math class.

More about this tip

External Source

Interview with Joon Kim

Other Tips By