Reflections on Learning C++: Depth-First Search and Algorithm Fundamentals

Reflections on Learning C++: Depth-First Search and Algorithm Fundamentals

Recently, the child struggled with understanding depth-first search in C++, and since they did not pass the GESP Level 4 exam in September, after discussing with the teacher, we attended a class together on November 16, 2025. It was quite rewarding. We explored the concepts of depth-first search and breadth-first search, particularly the offset of … Read more

Learning C++ Programming from Scratch, Day 422: 1208 – Spiral Matrix; Question Bank Answers; Fourth Method

Learning C++ Programming from Scratch, Day 422: 1208 - Spiral Matrix; Question Bank Answers; Fourth Method

1208 – Spiral Matrix Program Development Approach 1. Problem Analysis This program attempts to generate an n×n spiral matrix using a recursive method. The spiral matrix starts from the top-left corner (1,1) and fills numbers in a clockwise direction (right → down → left → up). 2. Algorithm Selection The program uses a depth-first search … Read more

C Language Algorithms: Depth-First Search and Breadth-First Search

C Language Algorithms: Depth-First Search and Breadth-First Search

In computer science, a graph is an important data structure. Graph traversal is a fundamental operation for processing graphs, and Depth-First Search (DFS) and Breadth-First Search (BFS) are two commonly used graph traversal algorithms. This article will provide a detailed introduction to these two algorithms along with corresponding C language code examples. 1. Depth-First Search … Read more

Tarjan’s Algorithm for Finding the Lowest Common Ancestor (LCA)

Tarjan's Algorithm for Finding the Lowest Common Ancestor (LCA)

1. Introduction When dealing with tree structures, it is common to encounter the need to find the Lowest Common Ancestor (LCA) of two nodes. The LCA is defined as the furthest node from the root among all common ancestors of the two nodes in the tree (i.e., the node with the maximum depth). For example, … Read more

C++ Search Algorithms: Depth-First Search and Breadth-First Search

C++ Search Algorithms: Depth-First Search and Breadth-First Search

C++ Search Algorithms: Depth-First Search and Breadth-First Search In computer science, search algorithms are essential tools for solving problems related to graphs, trees, and other structures. The two fundamental search strategies are Depth-First Search (DFS) and Breadth-First Search (BFS). This article will provide a detailed introduction to these two algorithms and demonstrate them using C++ … Read more