Linked lists and Binary trees

This is a discussion on Linked lists and Binary trees within the A Brief History of Cprogramming.com forums, part of the Community Boards category; What are the differences between a linked list and a binary tree...And also what one is better... Thank you any ...

  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,136

    Here's a visual example

    Linked List
    Code:
          |
          |
          |
          |
          |

    Binary Tree
    Code:
              |
            /   \
           /\   /\

  3. #3
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    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, 10:22 PM
  2. Linked Lists 101
    By The Brain in forum C++ Programming
    Replies: 5
    Last Post: 07-24-2004, 05: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

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