Trees: Glossary

    Trees: Glossary

      Balanced binary tree: If a binary tree's balanced, every left subtree of every node in a balanced binary tree is only, at most, one level different in height than the node’s right-subtree. Nobody likes unbalanced binary trees.

      Binary search tree (BST): Look for greater values to the right and lesser values to the left, but no apples here.

      Branches: Executive, Legislative, and Judicial make up the three...oh wait, we're in Computer Science. Here, branches are the various edges of a tree.

      Child: A node one level lower than its parent node, connected to that parent node with an edge (read: branch). What's that? Where do they come from? Uh…storks.

      Complete tree: Every level in the tree is completely filled, except maybe the last level, but that one is filled from left to right

      Directed graph: A one-way graph. You can only travel one direction, but don’t let it drag you down.

      Edges: Connections between nodes in a tree or any other graph. It could also be multiple U2 lead guitarists, but if you hear a computer scientist talking about it, they probably mean connections between nodes.

      Forest: A collection or cluster of unconnected trees

      Full tree: An n-ary tree is full when every node (except the leaf nodes) has n children.

      Height: The number of levels of nodes a particular tree has, but you start with 0 at the root, which means a tree with two levels has a height of 1. It’s all very confusing, but that's counting in computer science for you.

      Infix notation: The way humans prefer to write mathematical expressions because putting the operators between the numbers they apply to just makes sense, at least to non-binary brains. (2 + 2 is a good example.)

      In-order traversal: When you iterate through a tree by first visiting the left subtree, then visiting the current node, then visiting the right subtree, and then take a snack break.

      Internal nodes: Nodes that aren’t the root or leaves of a tree, because those aren’t internal…or eternal for that matter.

      Leaves: These nodes are the farthest away from the root (and have an out-degree of 0), but they don’t ever forget their roots

      n-ary tree: A tree where at least one node has an out-degree of n (binary, ternary, quaternary, ordinary, extraordinary, etc.)

      Perfect tree: All trees are perfect in their own special ways to us, but the most perfect ones are defined by having the root and all internal nodes connected to n children, where n is the type of n-ary tree it is.

      Post-order traversal: When you iterate through a tree by first visiting the left subtree, then visiting the right subtree, and then visiting the current node. The current node comes at the end, hence the whole post- thing.

      Pre-order traversal: When you iterate through a tree by first visiting the current node, then visiting the left subtree, and then visiting the right subtree. The current node comes first, hence that whole pre- thing.

      Parent: Every node has a parent—except the root, which just exists—and you’ll find that parent one level higher than the child attached to it.

      Polish notation (also called Prefix notation or PN): A way of writing mathematical expression so that the operators come before the numbers they act upon. It looks something like this: + 2 2. Humans don’t like it so much, but machines do.

      Reverse Polish notation (also called Postfix notation or RPN): In case it isn’t obvious, this is the reverse of Polish Notation, which means the operators come after the numbers they act on. It looks something like this: 2 2 +.

      Root: The granddaddy of all nodes. The root is the node that all other nodes on a tree span outward/away from.

      Self-balancing tree: A tree that balances itself. Did you really look this up? Anyway, it runs a balancing algorithm at every step of its creation, so it can’t stay unbalanced for long.

      Subtree: Smaller trees within trees, made up of only some of all the tree’s nodes. Don't do what we did and confuse it with a tree sub. Unless you love the taste of sawdust, you're better off not trying it.

      Tree: A tall plant you can climb, if you like that sort of thing. It's also a kind of graph that has, at most, only one path between any two nodes

      Undirected graph: A graph whose edges don't restrict travel (you can go along each edge in any direction you want, as long as you stay on the edge, which really means you only have two directions, but either of those two directions is totally fine).