From Computer Science Wiki
Jump to: navigation, search
Programming basics[1]

In computer science, a tree is a widely used abstract data type (ADT)—or data structure implementing this ADT—that simulates a hierarchical tree structure, with a root value and subtrees of children with a parent node, represented as a set of linked nodes.

A tree data structure can be defined recursively (locally) as a collection of nodes (starting at a root node), where each node is a data structure consisting of a value, together with a listGive a sequence of brief answers with no explanation. of references to nodes (the "children"), with the constraints that no reference is duplicated, and none points to the root.[2]

Image of a tree

Binary tree.svg.png

tree vocabulary

  • root node
  • parent node
  • child node
  • leaf node

Practical applications of a tree

  • Trees can be used to store data that has an inherent hierarchical structure. For example, an operating system may use a tree for directories, files and folders in its file management system.
  • They are dynamic, which means that it is easy to add and delete nodes.
  • They are easy to search and sort using standard traversal algorithms.
  • They can be used to process the syntax of statements in natural and programming languages so are commonly used when compiling programming code.

Tree - video example

This video provides a basic introduction to trees. It also summarizes, very nicely, other data structures. Please keep in mind the example at the beginning is not a binary tree, but binary trees are discussed later. Ignore the discussion about cousins and uncles. It's ridiculous. But the rest of the video is really good.


  • DescribeGive a detailed account or picture of a situation, event, pattern or process. how trees operate logically (both binary and non-binary).
  • DefineGive the precise meaning of a word, phrase, concept or physical quantity. the terms: parent, left-child, right-child, subtree, root and leaf.
  • StateGive a specific name, value or other brief answer without explanation or calculation.Give a specific name, value or other brief answer without explanation or calculation. the result of inorder, postorder and preorder tree traversal.
  • SketchRepresent by means of a diagram or graph (labelled as appropriate). The sketch should give a general idea of the required shape or relationship, and should include relevant features. binary trees.

See Also

External Links

high level discussion of binary trees