15,745,336 members
1.00/5 (1 vote)
See more:
An imaginary compiler uses an imaginary array ordering to represent multi-dimensional arrays into 1-D arrays.Say,this imaginary ordering is called spiral ordering.It works like:
Given 2-D array-{{1,2,3,4}{5,6,7,8}{9,10,11,12}{13,14,15,16}} then the 1-D array will be {1,2,3,4,8,12,16,15,14,13,9,5,6,7,11,10}
Deduce the general formula for calculating the address of an element at (x,y) position in a 2-D array,given the address of the element at (0,0).
Posted
Patrice T 26-Sep-15 17:37pm
Looks like homework !
Have you deviced a formula ? Imaginary speaking :)
Member 12011302 27-Sep-15 4:10am
Am able to print the matrix in Spiral form but have not yet deviced the formula...confused about that one!Help will be appreciated!

## Solution 1

As an imaginary responder I imagine this is your homework, so don't expect other people to do it for you.

Member 12011302 27-Sep-15 4:11am
Can you just help me device the general formula?I have written a code that will print matrix in spiral form but confused about the address part...
Richard MacCutchan 27-Sep-15 7:49am
Not really, since I do not understand the question.