next up previous contents
Next: A Note About Software Up: Sparse Arrays Previous: An Implementation

How Space-Efficient Are Sparse Arrays?

In the implementation shown in sa.c, on the HP workstations (which use 4-byte integers and 4-byte pointers) the space requirements of an n by n sparse array containing m non-zero elements are:

As we can see, this representation is not worthwhile unless the arrays are indeed fairly sparse: each element requires at least 6 times as much memory to represent as it would in an ordinary array. (If only row or column lists are maintained, then the requirements are cut in half, but this may have a profound effect on the running time of algorithms that access the array.)



Dan Ellard
Mon Jul 21 22:30:59 EDT 1997