Binary Trees?

This is a discussion on Binary Trees? within the C++ Programming forums, part of the General Programming Boards category; They are being talked about lately, and i know this is a noobish question but what are they used for? ...

  1. #1
    Registered User
    Join Date
    Nov 2004
    Location
    Pennsylvania
    Posts
    434

    Binary Trees?

    They are being talked about lately, and i know this is a noobish question but what are they used for? I am somewhat familiar with what they look like:

    1
    / \
    0 1
    / \ / \
    0 1 0 1

    That example probably isnt right but what are they? Why are they useful? And how are they implemented? If there is a good tutorial or website or something just let me know. Thanks!

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,319

  3. #3
    Registered User
    Join Date
    Nov 2004
    Location
    Pennsylvania
    Posts
    434
    Thanks ill read it over.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >but what are they used for?
    A lot of things. That's probably not helpful, so consider a canonical example of trees: a directory structure. Chances are very good that the computer you're using has directories structured as a tree. You have a root directory, / or C:/, and then nested within the root directory are files (which could be considered leaf nodes), and other directories (non-leaf nodes). That's not only a tree, but a tree that clearly displays the recursive nature of trees. But it's not a binary tree, or a binary search tree, which is likely what you mean when you say binary tree.

    A binary search tree can be used for any number of things, but most commonly it's used to store data in a way that it can be found quickly. That means simple in-core databases, symbol tables, etc. You can also take advantage of certain easy to implement properties, such as ignoring duplicate items to make a frequency table/histogram. Binary search trees can be used as cache's (and often are in the form of splay trees), a quick way to sort large amounts of data, and of course, any divide and conquer algorithm is easier to analyze if you use a binary or m-ary tree to represent the recursion.
    My best code is written with the delete key.

  5. #5
    Super Moderater.
    Join Date
    Jan 2005
    Posts
    374
    Here's another useful site about binary trees.

    http://www.cs.usask.ca/resources/tut...ree_index.html

    There's not much actual code but this is made up by the site's use of interactive applets. If you know what is going on visually, then in theory the coding should be easier.

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 wvu2005 in forum C Programming
    Replies: 7
    Last Post: 10-15-2005, 04:59 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Tutorial review
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-22-2004, 08:40 PM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM

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