Re: [algogeeks] Symmetric matrix

2011-01-21 Thread Umer Farooq
We can also use jagged arrays for this purpose

int[][] symmetric_matrix = new int[size][];

for (int i=0; i  size; i++)
...symmetric_matrix[i]=new int[max_diagonal/(size)];



On Wed, Jan 12, 2011 at 9:30 AM, Sathaiah Dontula don.sat...@gmail.comwrote:

 1 + 2 +  + n ( max diagonal) = n ( n + 1) / 2.
 Max elements you can store is n ( n + 1) / 2 .
 You can take an array of size n (n + 1) / 2 and store them.

 Thanks,
 Sathaiah

 On Wed, Jan 12, 2011 at 9:50 AM, Azhar Hussain azhar...@gmail.com wrote:

 I have a symmetric matrix. I am wondering what would be the best data
 structure to store such a matrix? How many elements do I need to store for a
 nxn matrix?

 Thanks in advance for the help.

 -
 Azhar.

 --
 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 to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 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 algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Umer

-- 
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 to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Symmetric matrix

2011-01-13 Thread Azhar Hussain
I am wondering what data structure would best suit for this?

-
Azhar.

On Wed, Jan 12, 2011 at 11:11 AM, Abdul Rahman Shariff
ears7...@gmail.comwrote:

 i can tell 1 thing tht only
 (((n*n)-n)/2) +n elements are unique and the (((n*n)-n)/2) term is the
 one shoes the no of repeated elements and n represents the
 diagonal elements hope this gives some usefull info (i havent gone through
 any book nor do i guarantee optimal or best memory usage)


 On Wed, Jan 12, 2011 at 9:50 AM, Azhar Hussain azhar...@gmail.com wrote:

 I have a symmetric matrix. I am wondering what would be the best data
 structure to store such a matrix? How many elements do I need to store for a
 nxn matrix?

 Thanks in advance for the help.

 -
 Azhar.

 --
 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 to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Ehab Abdul Rahman Shariff

 --
 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 to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 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 algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Symmetric matrix

2011-01-13 Thread juver++
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 algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Symmetric matrix

2011-01-13 Thread Azhar Hussain
Thanks for the help. It may not be symmetric on a diagonal. I have to
consider both situations

-
Azhar.

On Thu, Jan 13, 2011 at 3:37 PM, juver++ avpostni...@gmail.com 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 algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 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 algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Symmetric matrix

2011-01-13 Thread Sathaiah Dontula
1 + 2 +  + n ( max diagonal) = n ( n + 1) / 2.
Max elements you can store is n ( n + 1) / 2 .
You can take an array of size n (n + 1) / 2 and store them.

Thanks,
Sathaiah

On Wed, Jan 12, 2011 at 9:50 AM, Azhar Hussain azhar...@gmail.com wrote:

 I have a symmetric matrix. I am wondering what would be the best data
 structure to store such a matrix? How many elements do I need to store for a
 nxn matrix?

 Thanks in advance for the help.

 -
 Azhar.

 --
 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 to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 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 algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Symmetric matrix

2011-01-13 Thread Umer Farooq
Well, u can use List of Lists. The List would contain head nodes of all the
lists and each list would contain a row. The length of every list will be 1
greater than the next of it's next list.

In this way:

The tail of list would contain a diagonal element which

   L
 L1  1
 L2  4 2
 L3  4 3 4
 L4  5 4 4 2


On Thu, Jan 13, 2011 at 2:50 PM, Azhar Hussain azhar...@gmail.com wrote:

 I am wondering what data structure would best suit for this?

 -
 Azhar.


 On Wed, Jan 12, 2011 at 11:11 AM, Abdul Rahman Shariff ears7...@gmail.com
  wrote:

 i can tell 1 thing tht only
 (((n*n)-n)/2) +n elements are unique and the (((n*n)-n)/2) term is the
 one shoes the no of repeated elements and n represents the
 diagonal elements hope this gives some usefull info (i havent gone through
 any book nor do i guarantee optimal or best memory usage)


 On Wed, Jan 12, 2011 at 9:50 AM, Azhar Hussain azhar...@gmail.comwrote:

 I have a symmetric matrix. I am wondering what would be the best data
 structure to store such a matrix? How many elements do I need to store for a
 nxn matrix?

 Thanks in advance for the help.

 -
 Azhar.

 --
 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 to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Ehab Abdul Rahman Shariff

 --
 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 to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 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 algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Umer

-- 
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 to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Symmetric matrix

2011-01-11 Thread Abdul Rahman Shariff
i can tell 1 thing tht only
(((n*n)-n)/2) +n elements are unique and the (((n*n)-n)/2) term is the one
shoes the no of repeated elements and n represents the
diagonal elements hope this gives some usefull info (i havent gone through
any book nor do i guarantee optimal or best memory usage)


On Wed, Jan 12, 2011 at 9:50 AM, Azhar Hussain azhar...@gmail.com wrote:

 I have a symmetric matrix. I am wondering what would be the best data
 structure to store such a matrix? How many elements do I need to store for a
 nxn matrix?

 Thanks in advance for the help.

 -
 Azhar.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Ehab Abdul Rahman Shariff

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