The way u print a matrix in spiral order, same logic u can use to form the
matrix from given input PROVIDED the order of matrix is given ...
and this can be done in O(m x n) complexity...
--Negi
--~--~-~--~~~---~--~~
You received this message because you ar
question is to form a spiral metrix
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email
Both problems are essentially the same. You need to traverse the matrix in a
spiral order and has a pretty straight forward solution.
-Vijju
On 12/6/06, Lego Haryanto <[EMAIL PROTECTED]> wrote:
>
> Looking at the original question at the beginning at this thread, ... I
> really can't rephrase it
Looking at the original question at the beginning at this thread, ... I
really can't rephrase it to the one you just mentioned. All it needs is the
"matrix", ... who cares about printing it out.
On 12/5/06, Vikram Venkatesan <[EMAIL PROTECTED]> wrote:
>
> Hi,
> I think the question is not to
Hi,
I think the question is not to FORM A MATRIX, but to PRINT the elements
in the form of spiral matrix, where the problem of SEQUENTIAL OUTPUT
comes...
-Vikram
On 12/6/06, Gene <[EMAIL PROTECTED]> wrote:
>
>
>
> hijkl wrote:
> > this question was asked by Google..
> > "Write a program of sp
hijkl wrote:
> this question was asked by Google..
> "Write a program of spiral matrix"
> ie. it takes inputs and puts in to matrix as a spiral..example.
> given : 3 X 4 matrix
> your input in this order : 1 5 8 9 10 7 4 8 0 2 3 6
> will generate following matrix
>
> 1 5 8 9
> 2 3 6 10
Should be O(n) where n is the number of inputs.
Keep a displacement info for 4 directions ... strictly in this order: right,
down, left, up. Starting from the top left corner/cell and current
direction is right ... continue putting the numbers one by one and advance
the cell based on your current