O.k. here's the usual stuff first:
  • Compiler = Visual C++ 6.0
  • OS = WinXP
  • Part of a school assignment: Not directly
  • Using the following class:
    Code:
    // linked list node
    template <typename T>
    class node
    {
       public:
          T nodeValue;      // data held by the node
          node<T> *next;    // next node in the list
    
          // default constructor with no initial value
          node() : next(NULL)
          {}
    
          // constructor. initialize nodeValue and next
          node(const T& item, node<T> *nextNode = NULL) : 
    			  nodeValue(item), next(nextNode)
          {}
    };


I'm working on an assignment where I'm supposed to use linked lists. I'm really having a hard time understanding how they work and all that. For the assignment I'm doing I only need to use a singly linked list.

The main issue I'm running into is that I don't understand linked lists. I'm well familiar with sequential data structures.

Here's how I understand it. Please correct me if I'm wrong on this.

The elements of the singly linked list are as follows:
  • Front // Front element in the list
  • Curr // All elements in the list that are not Front and/or Back
  • Back // Back element in the list

Now if a linked list has 10 elements, the the way I'd reference the elements is as follows:
  • To access (insert/modify/delete) the second element in the linked list, I would refer to front->next.
  • Then to I would then make a comment like curr = front->next; assigning the nodeValue of the second element to curr.
  • To access the third element I would do the same thing. curr = curr->next;
  • Then so on and so forth.


Does this sound correct to anyone?