Computer Science, asked by sucheta98, 1 year ago

what are advantages and disadvantages of maintaining graph in the memory of a computer​

Answers

Answered by Immanjeet
2

Answer:

Storing nodes as objects with pointers to one another

The memory complexity for this approach is O(n) because you have as many objects as you have nodes. The number of pointers (to nodes) required is up to O(n^2) as each node object may contain pointers for up to n nodes.

The time complexity for this data structure is O(n) for accessing any given node.

Storing a matrix of edge weights

This would be a memory complexity of O(n^2) for the matrix.

The advantage with this data structure is that the time complexity to access any given node is O(1).


sucheta98: Thank you
Similar questions