ArticleslgStudy

science

Binary tree

Binary tree is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Binary tree rather than just read about it. In short: In computer science, a binary tree is a tree data structure in which each node has at most two children, referred to as the left child and the right child. That is, it is a k-ary tree where k = 2.

Binary tree — main illustration
Binary tree — illustration

Key takeaways

  • Binary tree belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Binary tree to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Binary tree from memory before moving on to harder problems.

Reference excerpt

In computer science, a binary tree is a tree data structure in which each node has at most two children, referred to as the left child and the right child. That is, it is a k-ary tree where k = 2. A recursive definition using set theory is that a binary tree is a triple (L, S, R), where L and R are binary trees or the empty set and S is a singleton (a single–element set) containing the root. From a graph theory perspective, binary trees as defined here are arborescences. A binary tree may thus be also called a bifurcating arborescence, a term which appears in some early programming books before the modern computer science terminology prevailed. It is also possible to interpret a binary tree as an undirected, rather than directed graph, in which case a binary tree is an ordered, rooted tree. Some authors use rooted binary tree instead of binary tree to emphasize the fact that the tree is rooted, but as defined above, a binary tree is always rooted. In mathematics, what is termed binary tree can vary significantly from author to author. Some use the definition commonly used in computer science, but others define it as every non-leaf having exactly two children and don't necessarily label the children as left and right either. In computing, binary trees can be used in two very different ways:

First, as a means of accessing nodes based on some value or label associated with each node. Binary trees labelled this way are used to implement binary search trees and binary heaps, and are used for efficient searching and sorting. The designation of non-root nodes as left or right child even when there is only one child present matters in some of these applications, in particular, it is significant in binary search trees. However, the arrangement of particular nodes into the tree is not part of the conceptual information. For example, in a normal binary search tree the placement of nodes depends almost entirely on the order in which they were added, and can be re-arranged (for example by balancing) without changing the meaning. Second, as a representation of data with a relevant bifurcating structure. In such cases, the particular arrangement of nodes under and/or to the left or right of other nodes is part of the information (that is, changing it would change the meaning). Common examples occur with Huffman coding and cladograms. The everyday division of documents into chapters, sections, paragraphs, and so on is an analogous example with n-ary rather than binary trees.

Definitions

Recursive definition

Recursive full tree definition A simple, informal approach to describe a binary tree might be as follows:

a binary tree has a root node, which has 0 or 2 children nodes (which in turn may have their 0 or 2 children, and so on). More formally:

(base case) There exists a full tree consisting of a single node; (recursive step) If T1 and T2 are full binary trees, which do not share any node, and r is a node not belonging to T1 or T2, then the ordered triple (r, T1, T2) is a full binary tree. This definition implies two limitations: a full binary tree contains at least one node, and no node can have only one child. This is resolved with the next definition.

Recursive extended tree definition The extended tree definition starts with the assumption the tree can be empty.

(base case) An empty set of nodes is an extended binary tree. (recursive step) If T1 and T2 are extended binary trees, which do not share any node, and r is a node not belonging to any of them, then the ordered triple (r, T1, T2) is an extended binary tree. To be complete from the graph point of view, both definitions of a tree should be extended by a definition of the corresponding branches sets. Informally, the branches set can be described as a set of all ordered pairs of nodes (r, s) where r is a root node of any subtree appearing in the definition, and s is a root node of any of its T1 and T2 subtrees (in case the respective subtree is not empty). Another way of imagining this construction (and understanding the terminology) is to consider instead of the empty set a different type of node—for instance square nodes if the regular ones are circles.

Using graph theory concepts A binary tree is a rooted tree that is also an ordered tree (a.k.a. plane tree) in which every node has at most two children. A rooted tree naturally imparts a notion of levels (distance from the root); thus, for every node, a notion of children may be defined as the nodes connected to it a level below. Ordering of these children (e.g., by drawing them on a plane) makes it possible to distinguish a left child from a right child. But this still does not distinguish between a node with left but not a right child from a node with right but no left child. The necessary distinction can be made by first partitioning the edges; i.e., defining the binary tree as triplet (V, E1, E2), where (V, E1 ∪ E2) is a rooted tree (equivalently arborescence) and E1 ∩ E2 is empty, and also requiring that for all j ∈ { 1, 2 }, every node has at most one Ej child. A more informal way of making the distinction is to say, quoting the Encyclopedia of Mathematics, that "every node has a left child, a right child, neither, or both" and to specify that these "are all different" binary trees.

Types of binary trees Tree terminology is not well-standardized and therefore may vary among examples in the available literature.

A rooted binary tree has a root node and every node has at most two children.

… excerpt ends here. Continue reading the full article.

Illustrations

Binary tree: A labeled binary tree of size 9 (the number of nodes in the tree) and height 3 (the height of a tree defined as the number of edges or links from the top-most or root node to the farthest leaf node), with a root node whose value is 1. The above tree is unbalanced and not sorted.
A labeled binary tree of size 9 (the number of nodes in the tree) and height 3 (the height of a tree defined as the number of edges or links from the top-most or root node to the farthest leaf node), with a root node whose value is 1. The above tree is unbalanced and not sorted.
Binary tree: A full binary tree
A full binary tree
Binary tree: An ancestry chart which can be mapped to a perfect 4-level binary tree.
An ancestry chart which can be mapped to a perfect 4-level binary tree.
Binary tree: A complete binary tree (that is not full)
A complete binary tree (that is not full)
Binary tree: A small complete binary tree stored in an array
A small complete binary tree stored in an array

Worked examples

Example 1 — a first encounter with Binary tree

Start with the simplest possible case. Write down what Binary tree claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Binary tree before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Binary tree ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Binary tree

In research
Binary tree appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Binary tree in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Binary tree is common in secondary-school and first-year university syllabi. It links to neighbouring topics Binary trees, so understanding it makes those chapters shorter.
In everyday life
Look for Binary tree outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Binary tree” →

How to study Binary tree in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Binary tree means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Binary tree out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Binary tree in simple terms?

In computer science, a binary tree is a tree data structure in which each node has at most two children, referred to as the left child and the right child. That is, it is a k-ary tree where k = 2.

Why does Binary tree matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Binary tree?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Binary tree.

Tags

  • Binary trees

Keep exploring