30 Days of Algorithms: From Zero to Intermediate (12/30) — Binary Tree

Tomas Svojanovsky
2 min readMay 27, 2024

A tree is a hierarchical data structure.

Data structures such as lists, queues, and stacks are linear. Their items are stored in a sequential way. However, a tree is a non-linear data structure because there is a parent-child relationship between the items.

Terminology

  • Node — It is a fundamental building block that holds data and references to other nodes
  • Root — It is the topmost node in the tree. In every tree there is always one unique root node
  • Subtree — It's a smaller part of tree that’s contained entirely within a larger tree
  • Degree — The total number of children a given node has
  • Leaf node —It's a node that doesn't have any children. The degree of leaf node is always 0
  • Edge — The connection between any two nodes. The number of edges in a tree is always one less than the number of nodes
  • Sibling — Nodes with the same parent
  • Level — It refers to vertical distance from the root node to any node. The level of root node is zero. The children of root node have level 1
  • Height of a tree — It’s the number of edges from the root node to the farthest leaf node

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Tomas Svojanovsky

I'm a full-stack developer. Programming isn't just my job but also my hobby. I like developing seamless user experiences and working on server-side complexities