Sample Sorted Linked List?

Is there anyone that can give me a simple example of a sorted linked list in c++?
I'm currently taking a CIS course on pointers and sorting lists and we have to make a sorted linked list using specific requirements which I would edit later.

I'm hoping someone could make a very simple sorted linked list with 3 sample un-ordered numbers so I can learn from it. I have a difficult problem learning how to do it straight from words, I need some kind of visual example, I learn it best this way.

Thanks!
Here's a starter:
1
2
3
4
5
6
7
struct Node {
    int data;
    Node * next;
};

// empty list
Node * root = 0;
Sample linked list for visual learners:
+---+    +---+    +---+
| 1 |--->| 2 |--->| 3 |--->
+---+    +---+    +---+

The list has 3 nodes: the first, storing the data 1; the second, storing the data 2; and the last, storing the data 3.

Note that the box represents a node, inside the node is the data, and the arrow represents the pointer to the next node. The last node of list's next pointer will be null.
Topic archived. No new replies allowed.