Practices
  Home arrow Practices arrow Trees
FaxWave - Free Trial.
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PRACTICES

Trees
By: Mohamed Saad
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 19
    2005-02-01

    Table of Contents:
  • Trees
  • Representation
  • Dictionary example
  • Putting it Together
  • Internet Browser
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Trees
    (Page 1 of 6 )

    Trees are remarkably useful and powerful data structures, with many applications. Mohamed El Dawy explains.

    In this article, I am going to give an introduction to trees. Trees are unique data structures that are used to store data in a tree-like shape. They have many useful applications, which include 3D programs, data compression, Web browsers and even dictionaries. All in all, trees are wonderful data structures. Let's get started.

    What are trees?

    As I said, trees are a kind of data structure. If the phrase "data structure" is new to you, don't worry. It just means the way you represent data in the memory of a computer. So, trees are no more than a method for storing data in the memory of a computer. Which type of data? And when should we use trees? This is what we are going to discuss in a moment.

    Trees look like the following diagram. First we have a root node which contains one item of data. The root node has some children,  and each one contains one item of data. Each one of the children, in turn, has some children, and so on...

    In essence, it looks something like this:

     
    Fig.1 An example of a tree

    Now, you may find this pretty weird. Why would someone want to represent data that way? Let's assume we have a list of n numbers; what is the point of putting them in a tree? As we are about to see, there are some good reasons to do so. Additionally, in real life, there are several applications where trees are just the natural way to represent data.

    First, before we go too far, let's look at some theory. Any tree can be represented by a tree where each node has a maximum of two children. This is called a "binary tree". A famous method to accomplish this is called "Left child, right sibling," but this is quite outside the scope of this article; check the further reading at the end of the article if you really need to know how to do it.

    A binary tree looks something like this:

     
    Fig 2. An example of a binary tree

    Why did I introduce this? It has a very important implication. We don't need to study general trees in depth, since any tree can be represented as a binary tree. It makes sense then that, from now on, we will only focus on binary trees. As I said, we are not limiting ourselves, because any tree can be represented by a binary tree.

    First, let's examine this fundamental problem: how can we represent a tree inside the computer memory?

    More Practices Articles
    More By Mohamed Saad


       · This article is difficult to follow and seems poorly organized for the first three...
       · Dear David, Thank you very much for reading the article, and for having the time...
       · I did not dislike the article necessarily - there were just a lot of things in it...
       · While it is true that all tree data -can- be represented as a binary tree, there are...
     

       

    PRACTICES ARTICLES

    - Basic Data Types and Calculations
    - What`s the Address? Pointers
    - Design with ArgoUML
    - Pragmatic Guidelines: Diagrams That Work
    - Five-Step UML: OOAD for Short Attention Span...
    - Five-Step UML: OOAD for Short Attention Span...
    - Introducing UML: Object-Oriented Analysis an...
    - Class and Object Diagrams
    - Class Relationships
    - Classes
    - Basic Ideas
    - Choosing the Right Team
    - Trees
    - Basic Array Searching in C++
    - Solving Problems with Recursion




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway