Classic linked list problem.
http://en.wikipedia.org/wiki/Linked_list
Google on linked lists...
Either you can have single or double linked nodes.
With single linked nodes, you have to start at the head and traverse
the list until you've found the node under investigation.
With double linked nodes, you can traverse the list in either direction.
Benefits:
Single linked lists conserve memory
Double linked lists are more efficient for searching.
As far as inserting a node, you have to store the pointers of the two nodes
at the insertion point, update the to be inserted node with these pointers,
and change the pointers of original nodes to point to the newly inserted node.
When adding a node at the top of the list, you only have to deal with parent pointer
of the top node; which should NULL or false at that point.
Additionally, you won't be able to just use an "in-order"
traversal scheme (I mean the order that the nodes were inserted),
to traverse the list. You'll need methods to use the pointers to
follow the links.
But it sounds like you've already set that up.
Ergo, you just need to modify your "insertNode" method.
i.e.
- node = createNewNode();
- list->insertNode(0,node);