Linked List Tutorials

This is a discussion on Linked List Tutorials within the C++ Programming forums, part of the General Programming Boards category; Can anyone give me some urls to good linked list tutorials? The one here is good, but doesn't even go ...

  1. #1
    Satan valar_king's Avatar
    Join Date
    Aug 2001
    Posts
    288

    Unhappy Linked List Tutorials

    Can anyone give me some urls to good linked list tutorials? The one here is good, but doesn't even go as far as to cover doubly linked lists.

    Thanks,
    Valar_King
    -Save the whales. Collect the whole set.

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    For doubly linked lists, I suggest linking 2 together at the highest point, and then using pointers to access anything from the second list.

    _______________________
    Sean Mackrory
    sean_mackrory@hotmail.com

  3. #3
    Unregistered
    Guest

    The starting point...

    This code is incomplete. Work in progress...

    Code:
    typedef struct tagNode
    {
     struct tagNode *prev;
     char *data;
     long int ID;
     struct tagNode *next;
    }NODE;
    
    
    
    
    
    
    
    
    
    
    
    NODE *NewNode()
    {
     NODE *p;
    
     p = (NODE  *)malloc(sizeof(NODE ));
    
     p -> next = NULL;
     p-> prev =  NULL;
    
     return p;
    
    }
    
    
    
    
    
    
    
    
    
    
    
    
    void AddNode(NODE *p, NODE *head)
    {
    NODE *a;
    
     if(head == NULL)
     {
     head = p;
     return;
     }
    
     for(a = head; a->next != NULL; a = a->next)
     ;
    
    
     a->next = p;
     }
    
    
    
    
    
    
    
    
    
    
    
    void DeleteNode(NODE *p, NODE *head)
    {
     NODE *a;
    
     if(p == head)
     {
      head = p->next;
      free(p);
      return;
     }
    
     for(a = head; (a != NULL) && (a->next != p); a = a->next)
     ;
    
     a->next = a->next->next;
    
     free(p);
    }
    Those are the some basic building blocks.

    Port to C++ as desired

  4. #4
    Satan valar_king's Avatar
    Join Date
    Aug 2001
    Posts
    288
    heck, i can already make an app that lets you go forward and backward in a list of numbers, and delete and insert nodes. now that i've done doubly linked lists, i'd like to move on to more advanced things about it.
    -Save the whales. Collect the whole set.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ Linked list program need help !!!
    By dcoll025 in forum C++ Programming
    Replies: 1
    Last Post: 04-20-2009, 10:03 AM
  2. Linked List
    By jpipitone in forum C Programming
    Replies: 4
    Last Post: 03-30-2003, 08:27 PM
  3. How to use Linked List?
    By MKashlev in forum C++ Programming
    Replies: 4
    Last Post: 08-06-2002, 07:11 AM
  4. Template Class for Linked List
    By pecymanski in forum C++ Programming
    Replies: 2
    Last Post: 12-04-2001, 08:07 PM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21