IT lexicon Programming Binary tree

Binary tree

Programming På svenska → Updated: 2026-05-23

Hierarchical data structure where every node has at most two children (left and right). A building block for many other structures.

Variants: binary search tree (BST, sorted order), heap (parent is max/min of children), balanced tree (AVL, red-black, guaranteed height), trie, segment tree, Fenwick tree. Traversal: in-order, pre-order, post-order, level-order (BFS).

Unbalanced BSTs can degenerate into linked lists (O(n) operations) — always use balanced trees in production (every language's TreeMap is red-black).

← Back to the lexicon