[prev] 35 [next]

Adjacency Matrix Representation (cont)

Storage cost: V int ptrs + V2 ints

Storage optimisation: store only top-right part of matrix.

Cost of operations:

  • initialisation: O(V2)   (initialise V×V matrix)
  • insert edge: O(1)   (set two cells in matrix)
  • delete edge: O(1)   (unset two cells in matrix)