Tags

Level Order

Level Order

1 lesson
5 problems

level-order

Data Structures

1 lesson

Trees: Binary Tree Fundamentals

Free
Beginner

55 min

2 prereqs

Every web page you load is a tree (the DOM), every directory you `cd` into is a tree, every JSON document with nested objects is a tree, and every arithmetic expression a compiler parses is a tree. **Binary Tree Fundamentals** turns that ubiquitous shape into a precise data structure where each node has at most two children, named `left` and `right`. This lesson covers the vocabulary you need for the rest of the curriculum (root, leaf, parent, child, sibling, depth, height), the four common shape categories (full, complete, perfect, balanced) and the degenerate case that collapses to a chain, all four canonical traversals (preorder, inorder, postorder, and level-order BFS), and both recursive and iterative implementations of each. You will also analyze why traversals are `O(n)` time but only `O(h)` space when written recursively. In **Queue & Deque**, you saw that a FIFO queue processes items in arrival order; level-order traversal is exactly that pattern applied to tree nodes. In **Hash Map (Dictionary) Basics**, the bucket-by-key idea reappears here when you store parent-pointer mappings or memoize subtree results during a traversal. With binary trees in your toolkit, **Binary Search Tree (BST)** layers an ordering invariant on top to turn the same shape into a logarithmic-time search structure.

Not Started

0%

Trees
Binary Tree
Tree Traversal
Preorder
Inorder
Postorder
Level Order
Data Structures
Beginner
Free

Practice Problems

5 problems

Average of Levels in Binary Tree

Free
Not Started
Medium

Given the root of a binary tree, return the average value of the nodes on each level as an array.

Binary Tree
BFS
Queue
Level Order
Intermediate

1k

23

Binary Tree Level Order Traversal

Free
Not Started
Medium

Given the root of a binary tree, return the level order traversal of its nodes' values (from left to right, level by level).

Binary Tree
BFS
Queue
Level Order
Intermediate

1.1k

19

Binary Tree Right Side View

Free
Not Started
Medium

Given the root of a binary tree, return the values of the nodes you can see when looking at the tree from the right side, ordered from top to bottom.

Binary Tree
BFS
DFS
Level Order
Intermediate

409

2

Binary Tree Zigzag Level Order Traversal

Free
Not Started
Medium

Given the root of a binary tree, return the zigzag level order traversal of its nodes' values (alternating left-to-right and right-to-left for each level).

Binary Tree
BFS
Queue
Level Order
Intermediate

745

19

Populating Next Right Pointers II

Free
Not Started
Medium

Given a binary tree, populate each node's next pointer to point to its next right node. If there is no next right node, set it to null.

Binary Tree
BFS
Queue
Level Order
Intermediate

1k

30