SparkNotes Shopping Cart  |     |  Checkout
Brought to you by Barnes and Noble
  Home : Math & Science : Computer Science Study Guides : Trees : Intro : Different Shapes and Characteristics of Trees
Introduction to Trees
  
 
Different Shapes and Characteristics of Trees
Like real trees, tree data structures exhibit branching. This carries a number of implications.
First, one must consider the degree of a tree. This refers to the maximum number of children that a node can have. The most common form of tree in computer science is a binary tree, in which each node can have up to 2 children. There are however, ternary trees, with up to 3 children, quaternary trees with up to four children, and so forth.
The next element to consider is the overall size of the tree. There are a number of ways to quantify tree size. One is the longest path from the root node to a leaf node. This is called the depth. If you imagine a tree as having layers, the depth is the number of layers.
When describing a tree, it is often convenient to be able to describe its form in detail. There are several terms which describe the form of trees. A balanced tree is one where all of the leaves of the tree are within one layer of one of each other. For example:
Figure 1.1: Balanced Tree
is a balanced tree, whereas the following is not:
Figure 1.2: Unbalanced Tree
A complete tree is a type of balanced tree, except that it has one more additional constraint. In a balanced tree, all leaves are of depth n or n + 1. In a complete tree, all of the leaves of depth n + 1 are further to the left than the leaves of depth n. Furthermore, in a complete tree, all branch nodes (except those at depth n) must have the maximum number of children.
Figure 1.3: Complete Tree
A perfect tree is even more particular. It requires that all of the leaves be of the same depth and that every branching node has the maximum number of children.
Figure 1.4: Perfect Tree
Help | Feedback | Make a request | Report an error | Send to a friend
 
For students sick of scribbling geometry concepts on index cards, SparkNotes Study Cards are the answer.
More...
 
You'll flip over our Pre-Algebra Study Cards—writing out flashcards is now a thing of the past.
More...
 
 
Go to top