
Originally Posted by
judemartin99
How do I create an application that uses a linked list.
A (singly) linked list consists of nodes that usually look something like this,
Code:
class Node {
Data data;
Node next;
}
Each node holds some data. In the simplest case it could be an int. And each node is linked to the next node by holding a reference to it.
Then you need to come up with all the wanted operations on these linked nodes. Most involve you "walk" the chain of next references from the first up to the last node at the most (the one with a null next reference) and do something along the way. It could be you count the nodes to get the list length or you add a new node when you reach the end. Or you add it at the very beginning for that matter because it obviously is more efficient.