Binary trees in real life?

This is a discussion on Binary trees in real life? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I'm just a little bit curious... Is there any "binary tree" in real-life other than a simple family structure? ... ...

  1. #1
    Ugly C Lover audinue's Avatar
    Join Date
    Jun 2008
    Location
    Indonesia
    Posts
    489

    Question Binary trees in real life?

    I'm just a little bit curious...
    Is there any "binary tree" in real-life other than a simple family structure?

    ... Food cooking? ... Or something else?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Actually, a family tree is not strictly a binary tree, as it's possible to have more than two siblings to a parent node.

    Telephone exchanges used a tree hierarchy to find the actual target phone when dialing a phone number, for example. It is again not a binary tree, but a "decimal" tree with 10 nodes coming off each individual node. Of course, modern telephone exchanges are computerized, and the actual structure is not strictly a tree any longer.

    And of course the structure of taxonomy (scientific names of species) is a tree - again not a binary tree.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    A family tree isn't even a tree, because branches can merge again.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    Quote Originally Posted by CornedBee View Post
    A family tree isn't even a tree, because branches can merge again.
    Making it a "dag" (directed acyclic graph).
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  5. #5
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    Quote Originally Posted by brewbuck View Post
    Making it a "dag" (directed acyclic graph).
    In some places they allow cycles

  6. #6
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Wow, I'd like to see the time machine that makes this possible.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #7
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,069
    Quote Originally Posted by CornedBee View Post
    Wow, I'd like to see the time machine that makes this possible.
    Enough inbreeding will make anything seem possible.

    http://www.metacafe.com/watch/54702/im_my_own_grandpa/

    Note: This video or song contains nor condones any form of inbreeding. It's just cute.
    Last edited by SlyMaelstrom; 11-12-2008 at 12:04 PM.
    Sent from my iPad®

  8. #8
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    Quote Originally Posted by audinue View Post
    I'm just a little bit curious...
    Is there any "binary tree" in real-life other than a simple family structure?

    ... Food cooking? ... Or something else?
    Most decision-making processes can be represented as a binary tree. At each node of the tree a yes/no decision is made on some issue. Depending on which decision is made, another decision must be made, or some course of action is followed. So a path from root to leaf in this tree represents a chain of decisions which were made to arrive at that course of action.

    Decisions with more than two choices can still be represented as binary decisions. It just makes the tree deeper.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  9. #9
    Ugly C Lover audinue's Avatar
    Join Date
    Jun 2008
    Location
    Indonesia
    Posts
    489
    Quote Originally Posted by brewbuck
    At each node of the tree a yes/no decision is made on some issue. Depending on which decision is made, another decision must be made, or some course of action is followed. So a path from root to leaf in this tree represents a chain of decisions which were made to arrive at that course of action.
    Nice explanation brewbuck... Thanks.
    Btw, any example of cases in real-life about binary tree anyone?

  10. #10
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by audinue View Post
    Nice explanation brewbuck... Thanks.
    Btw, any example of cases in real-life about binary tree anyone?
    I thought brewbucks example IS that.

    Usually, at the back of your power-tools or such user's guide, there is a trouble-shooting guide:
    Machine doesn't start:
    Step 1.
    Is the power-plugged in?
    No - Plug it in,
    Yes - Go to step 2.
    2. Has the fuse blown?
    Yes - replace fuse.
    No - go to step 3.
    ... etc, etc.

    That's exactly a binary tree.

    Another form is "keys" for identifying species of animals, e.g. this one:
    http://www.auburn.edu/academic/scien...h_key/key.html

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  11. #11
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,435
    Another area where binary trees can be observed is in the language rules and are often used to build database dictionaries.

    Which is quite a fascinating area, that of expressing hierarchies and trees in RDBMs. I wholeheartedly advise one of the most fascinating SQL books ever written: Morgan Kaufamann Publishers - Trees and Hierarchies in SQL for Smarties, by Joe Celko. I stumbled upon this book on a bookshop in Glenelg (Australia) while hunting for something completely unrelated. I ended up leaving the shop with it and not what I went there for.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  12. #12
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Mario,

    I think Audinue is asking for examples OUTSIDE of computers.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  13. #13
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Quote Originally Posted by audinue View Post
    I'm just a little bit curious...
    Is there any "binary tree" in real-life other than a simple family structure?

    ... Food cooking? ... Or something else?
    The genetic material an offspring receives from its parents coudl be represented as a binar tree, since for each gene the child recieves either one copy or the other from a particular parent.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  14. #14
    Ugly C Lover audinue's Avatar
    Join Date
    Jun 2008
    Location
    Indonesia
    Posts
    489
    Yeah! I found it!

    http://www.greenteapress.com/thinkpy...ml/chap20.html

    Section 7 The animal tree

    This is a simplest implementation of binary tree (which I can tell to my students *giggle*)...
    It's often called "Animal Guess"

    I hope there is another example that simple to understand for kids between 12 and 15 years old...

    Cool... Thanks everyone for replying!
    Last edited by audinue; 11-13-2008 at 04:37 AM.

  15. #15
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    The animal tree is really just a different variant of the troubleshooting tree that I described earlier.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A Binary Search Tree of... Binary Search Trees...
    By SlyMaelstrom in forum C++ Programming
    Replies: 5
    Last Post: 12-10-2005, 01:12 PM
  2. binary trees
    By studentc in forum C Programming
    Replies: 1
    Last Post: 05-25-2004, 03:48 AM
  3. binary trees
    By Mr_Jack in forum C++ Programming
    Replies: 7
    Last Post: 03-09-2004, 08:49 PM
  4. Programming Puns
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 44
    Last Post: 03-23-2002, 03:38 PM
  5. real life...
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 35
    Last Post: 11-17-2001, 06:30 PM

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