Code for psiral traversal of a 2D array