Linked List Properties

This is a discussion on Linked List Properties within the C Programming forums, part of the General Programming Boards category; Is it standard for a linked list node to have both previous and next pointers? Code: struct node { int ...

  1. #1
    Climber spoon_'s Avatar
    Join Date
    Jun 2002
    Location
    ATL
    Posts
    182

    Linked List Properties

    Is it standard for a linked list node to have both previous and next pointers?


    Code:
    struct node
    {
            int data;
            struct node *prev;
            struct node *next;
    };

    spoon_
    {RTFM, KISS}

  2. #2
    Registered User
    Join Date
    Jul 2002
    Posts
    45
    Having two pointers makes it easier to traverse and edit the list.

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    For most applications, a next pointer will suffice. Only when you need more complex navigation both are needed. Note that you don't have to have just those two. And you can also have multidimensional lists, just as in an array...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    Unregistered
    Guest
    isn't a linked list with pointers next and previous a double-linked list?

  5. #5
    Registered User Unreg1stered's Avatar
    Join Date
    Jul 2002
    Posts
    25
    Yes, it's a double-linked list.

  6. #6
    Climber spoon_'s Avatar
    Join Date
    Jun 2002
    Location
    ATL
    Posts
    182
    Ahh, okay. A double linked list.

    thanks,
    spoon
    {RTFM, KISS}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 11:10 AM
  2. Reverse function for linked list
    By Brigs76 in forum C++ Programming
    Replies: 1
    Last Post: 10-25-2006, 11:01 AM
  3. How can I traverse a huffman tree
    By carrja99 in forum C++ Programming
    Replies: 3
    Last Post: 04-28-2003, 06:46 PM
  4. Template Class for Linked List
    By pecymanski in forum C++ Programming
    Replies: 2
    Last Post: 12-04-2001, 09:07 PM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 11:21 PM

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