Computer ScienceData StructuresMedium

Binary Tree

Also known as:Ordered binary treeBinary rooted tree

A binary tree is a hierarchical data structure in which each node has at most two children, referred to as the left child and the right child. It is one of the most fundamental structures in computer science, forming the basis for more specialized trees like binary search trees and heaps. Binary trees are widely used in expression parsing, Huffman coding, and database indexing.

Binary Tree Traversal Methods and Their Properties

TraversalOrderUse CaseTime Complexity
In-orderLeft → Root → RightSorted output in BSTO(n)
Pre-orderRoot → Left → RightTree serializationO(n)
Post-orderLeft → Right → RootTree deletionO(n)
Level-orderLevel by level (BFS)Shortest path problemsO(n)

Interactive Tools

Visualgo — Binary Tree Visualizer

Open Tool

CS USF — Binary Tree Visualization

Open Tool

Brilliant.org — Binary Trees

Open Tool
Diagram of a binary tree with nodes and left/right child pointers

Wikimedia Commons, CC BY-SA

Related Terms

The word "binary" derives from the Latin "binarius," meaning "consisting of two." The term has been used in computer science since the 1960s to describe tree structures where each node branches into at most two children.

treedata-structurehierarchytraversalcomputer-science