for graph type problems I've been using an adjacency matrix.
But now I'm dealing with an adjacency list type problem.
It seems to me that the most natural way to implement the list is to use linked list structure. But creating a list from scratch is kinda ... messy in my opinion. Using 2D arrays for matrix seems so much cleaner -- no messing with pointers.
But then if you're not using lists, how do you implement an adjacency list ?
Start Free Trial