if the matrix is n x n and n is not huge > 5k
Use int arr[((n * n) - n ) / 2 + n];

One approach:

arr[0] = n;
c = 1;
for (i=n; i >= 0; i--)
  for (j=0; j < i ; j++)
    arr[c++] = get_element_at(n-i, j);

And u can access any element in O(1).



Programmers should realize their critical importance and responsibility in a
world gone digital. They are in many ways similar to the priests and monks
of Europe's Dark Ages; they are the only ones with the training and insight
to read and interpret the "scripture" of this age.


On Thu, Jan 13, 2011 at 3:37 PM, juver++ <[email protected]> wrote:

> One-dimensional array.
> 1 2 4
> 2 3 5
> 4 5 6
> => [1, 2, 3, 4, 5, 6]
> Is your matrix summetric on a diagonal?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to