notes33 - Trees Big idea representing a hierarchy of...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Trees. Big idea: representing a hierarchy of information. What are trees good for? Hierarchy: world, countries, states, cities. Ordering: binary search trees. Composition: arithmetic operations at branches, numbers at leaves. The name “tree” comes from the branching structure of the pictures, like real trees in nature except that they’re drawn with the root at the top and the leaves at the bottom. A node is a point in the tree. In these pictures, each node includes a datum (the value shown at the node, such as France or 26 ) but also includes the entire structure under that datum and connected to it, so the France node includes all the French cities, such as Paris . Therefore, each node is itself a tree —the terms “tree” and “node” mean the same thing! The reason we have two names for it is that we generally use “tree” when we mean the entire structure that our program is manipulating, and “node” when we mean just one piece of the overall structure. Therefore, another synonym for “node” is “subtree.”
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/17/2010 for the course COMPUTER S 26275 taught by Professor Harvey,b during the Spring '10 term at Berkeley.

Ask a homework question - tutors are online