DSA Lesson 15 of 33

Binary Tree

Learn trees where each node has at most two children.

Course Progress45%

Theory

A binary tree is a tree data structure in which each node can have at most two children, commonly called the left child and right child. Binary trees are important for understanding binary search trees and tree traversal.

Example

class Node { constructor(value) { this.value = value; this.left = null; this.right = null; } } const root = new Node(10); root.left = new Node(5); root.right = new Node(15); console.log(root.value);

Expected Output

10

Practice

Create a binary tree with a root and two children.

Interview Questions

  1. What is a binary tree?
  2. How many children can a binary-tree node have?
  3. What are left and right children?
  4. What is a leaf?