Finding the Bottom-Left Value in a Binary Tree
Problem Overview
Continuing with binary tree traversal problems. This is problem 513: Find the value of the bottom-left node in a binary tree.
Problem Statement
Given the root of a binary tree, return the value of the bottommost-leftmost node in the tree. The tree has at least one node.
Example 1:
Input: root = [2, 1, 3]
Output: 1
Example 2:
I ...
Posted on Fri, 11 Sep 2026 16:22:58 +0000 by robcrozier
Comprehensive Guide to Binary Tree Traversals: Recursive and Iterative Approaches
Binary Tree Node Definition
public class BinNode {
int data;
BinNode leftChild;
BinNode rightChild;
BinNode() {}
BinNode(int data) {
this.data = data;
}
BinNode(int data, BinNode leftChild, BinNode rightChild) {
this.data = data;
this.leftChild = leftChild;
this.rightChild = rightCh ...
Posted on Tue, 08 Sep 2026 16:41:36 +0000 by phithe
Maximum Depth of Binary Trees: Recursive and Iterative Approaches
Maximum Depth of a Binary Tree
The maximum depth of a binary tree is defined as the number of nodes along the longest path from the root node down to the farthest leaf node. A leaf node is a node that has no children. This problem can be solved using either a recursive depth-first search approach or an iterative breadth-first search approach.
R ...
Posted on Thu, 13 Aug 2026 16:02:47 +0000 by Sj0wKOoMel
Generating Permutations and Combinations Using Depth-First Search
Permutations This article demonstrates a method for generating all permutations of a set of numbers using depth-first search (DFS).
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX_SIZE = 100010;
int size, sequence[MAX_SIZE];
bool visited[MAX_SIZE];
void generatePermutations(int ...
Posted on Tue, 04 Aug 2026 17:03:36 +0000 by nominator
Implementing Recursive Binary Tree Traversals: Preorder, Inorder, and Postorder
Constructing recursive tree traversal algorithms follows a standardized three-phase design pattern. First, establish the function signature by defining the node input and the container that will store traversal results. Second, define the termination condition to halt recursion when a leaf boundary is reached, usually by validating against a nu ...
Posted on Mon, 03 Aug 2026 16:48:43 +0000 by acirilo
Understanding Recursion Termination Conditions for Binary Tree Path Problems
LeetCode 257: Binary Tree All Paths
Termination Condition Considerations
The statement if (root == nullptr) return; serves multiple critical purposes in recursive tree algorithms:
Primary Function Guard
When placed in the main function provided by LeetCode, this check handles the empty tree case. If an empty tree is passed to the main function, ...
Posted on Sun, 12 Jul 2026 16:49:45 +0000 by knickerlas
Mastering Graph Search: DFS and BFS Strategies in Competitive Programming
Understanding Search Paradigms
When approaching algorithmic challenges involving traversal, two primary methods dominate: Depth-First Search (DFS) and Breadth-First Search (BFS). While both traverse nodes in a graph or tree, their utility differs based on the problem constraints. BFS is fundamentally tied to the concept of shortest paths in unw ...
Posted on Thu, 09 Jul 2026 17:24:30 +0000 by studot
Graph Algorithms for Island Problems in Go
Water Flow Simulation
Siumlate water flow using two visited matriecs for tracking.
Depth-First Search Implementation
package main
import "fmt"
var dirs = [][]int{{1, 0}, {-1, 0}, {0, 1}, {0, -1}}
func main() {
var rows, cols int
fmt.Scanln(&rows, &cols)
grid := make([][]int, rows)
vis1 := make([][]bool, ...
Posted on Thu, 09 Jul 2026 16:35:05 +0000 by Pryach
NOIP Simulation Contest - Problem Solutions and Reflections
Overview
This contest proved challenging despite seemingly moderate difficulty. The overall rating leans toward green to purple, but the execution was frustrating. T1 cost me significant points due to rushing through it—225 dropped to 175 points. Strategic lesson: even when T1 appears simple, allocating proper time (up to 1.5 hours is reasonabl ...
Posted on Wed, 08 Jul 2026 17:41:04 +0000 by x01440
Three LeetCode Problems: Binary Tree Split, Array Reduction, and Jump Game
Maximum Product of Splitted Binary Tree
Given a binary tree with root node, remove exactly one edge to split the tree into two separate subtrees. The goal is to maximize the product of the sums of both resulting subtrees. Return the result modulo 10^9 + 7.
Approach
The key insight is that during a depth-first search that calculates subtree sums ...
Posted on Mon, 29 Jun 2026 16:28:43 +0000 by sapoxgn