Trees

This is a discussion on Trees within the C++ Programming forums, part of the General Programming Boards category; What binary tree would be produce if inserting the elements in the following order ( DRAW THE TREE) 3 8 ...

  1. #1
    Unregistered
    Guest

    Trees

    What binary tree would be produce if inserting the elements in the following order ( DRAW THE TREE)

    3 8 5 17 30 23 54 76 66 67 8 78 98 2 7 88


    I know that 3 would be the smallest element and would be placed in the far left side of the tree and 98 would be in the far right side of the tree.

    How would i know which element would be the root?




    Thanks
    David

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    genrally the first element you add is the root of a binary tree.

    it would look something like the attached file (zipped bitmap)

    Cheers
    U.
    Attached Files Attached Files
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  3. #3
    Unregistered
    Guest
    thank you sooo much for taking the time to draw it for me i understand now

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    not a problem
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trees
    By masterg in forum C++ Programming
    Replies: 2
    Last Post: 12-04-2008, 01:42 PM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  3. Trees
    By samtay in forum C++ Programming
    Replies: 7
    Last Post: 03-28-2004, 09:35 AM
  4. Binary Trees...
    By SirCrono6 in forum C++ Programming
    Replies: 5
    Last Post: 11-25-2003, 04:54 PM
  5. AVL Trees
    By kwigibo in forum C Programming
    Replies: 2
    Last Post: 04-17-2002, 06:46 PM

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