The first question is: \"How I do a simple sparse array in C (with one dimension only)?\" {with my own hands, without libraries.}
And the last one: \"Can I allocate
It is not uncommon to implement these in linked structures of one kind or another. In one dimension you can simple generate a linked list of occupied regions, and I've discussed a two dimensional implementation in another context before.
You do lose O(1) access time this way, but the win on space can be considerable if the structure really is sparse.