Pregunta

So I have to make a sparse matrix base on circular linkedlist... but not sure how to start... So far I know i gotta have a Node class where I going to have something like Node class include those fields:

{
int value;
Node next, down;
int row,column;
}

Here an image of how sparse matrix for my assignment look like

I think I have to make the first node, which is enter, but not sure what next...

¿Fue útil?

Solución

Each node has references to its nearest neighbour in "forward" cartesian directions, so:

public class Node {
    Node right, down;
}

would be a reasonable start.

The fact that the matrix is sparce or circular is irrelevant if you use this design.

Typically, the main program would hold a reference to the "first" node, which is arbitrary but a reasonable choice would be the top left node.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top