Thread: Linked lists and Binary trees

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    2

    Linked lists and Binary trees

    What are the differences between a linked list and a binary tree...And also what one is better...

    Thank you any help is much needed...

    Scotty

  2. #2
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138

    Here's a visual example

    Linked List
    Code:
          |
          |
          |
          |
          |

    Binary Tree
    Code:
              |
            /   \
           /\   /\

  3. #3
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    Linked List
    Code:
    class NODE
    {  NODE* next;
    
        int data;
    }


    Binary Tree
    Code:
    class NODE
    {  NODE* left;
        NODE* right;
    
        int data;
    }

  4. #4
    Registered User
    Join Date
    Jul 2002
    Posts
    2

    Thank u

    I have the meaning of the to different types but what is the difference...
    Scotty

  5. #5
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    Linked lists are generally not sorted, and are fast to insert things into, regardless of their size, but searching them is very slow. Binary trees are generally sorted, have slower insertion times (albeit not that slow), but searching them is just as fast as insertion.
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linked Lists Vs Binary Search Tree
    By peckitt99 in forum C++ Programming
    Replies: 6
    Last Post: 08-13-2007, 09:22 PM
  2. Linked Lists 101
    By The Brain in forum C++ Programming
    Replies: 5
    Last Post: 07-24-2004, 04:32 PM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. Array, Linked List, or Binary Tree?
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 01-05-2002, 10:07 PM
  5. arrays, linear linked lists and binary trees
    By jasingle in forum C++ Programming
    Replies: 2
    Last Post: 11-12-2001, 11:12 AM