liveBook · Manning

Binary tree

As explained in Grokking Machine Learning, Second Edition

A tree data structure in which each node has at most two child branches.

Imagine deciding whether to wear a jacket: ask whether it is raining, then perhaps ask about the temperature. Following each yes-or-no answer moves down one branch of a binary tree. section 9.0

A binary tree contains nodes connected by edges. The top node is the root; a node may have two branches, while a leaf has none. Decision nodes hold questions, and each branch represents an answer. section 9.0

Useful structural terms include:

  • Root node: the topmost node containing the first question. section 9.0
  • Decision node: a node with two branches, one for each yes-or-no answer. section 9.0
  • Leaf node: a node with no outgoing branches and therefore a final result. section 9.0
  • Depth: the number of edges on the longest path from the root to a leaf. section 9.0

Decision stump

A decision stump is the smallest binary decision tree: one root question—“Is it raining?”—leading directly to two leaves: wear a jacket or do not wear one. Its depth is 1. section 9.0

How Grokking Machine Learning, Second Edition covers it

How deep it goes
Defines nodes, edges, branches, leaves, roots, and depth, but does not address implementation or tree algorithms.
Examples
Uses jacket decisions, raining and temperature questions, decision stumps, and depth-2 diagrams.
What you can do after
Evaluate a binary decision tree by identifying its parts, following branches, and measuring its depth.
How it connects
Connects binary trees with decision trees, root nodes, decision nodes, leaf nodes, branches, and tree depth.

Also explained in

Compare how 7 books explain binary tree →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Machine Learning, Second Edition. The section links point to the parts of the book it draws on.