liveBook · Manning

Stopping criterion

Also called stopping condition, stop condition, stopping criteria, termination condition, stopping rule

A stopping criterion is a condition or rule that determines when a process, computation, or sequence of actions should end.

How 14 Manning books explain it

Modern C, Third Edition

A condition is an expression whose evaluated value controls conditional or iterative execution in C.

How it is used
Uses conditions to control selection, iteration, recursive termination, and waiting for thread work.
How deep it goes
Explains evaluation order and termination through loop and recursion examples, while deferring the full range of condition-expression primitives.
Examples
Illustrates numerical truth with a printing loop, precision-based stopping with a reciprocal approximation, and recursive termination with a greatest-common-divisor function.
What you can do after
Apply it to write and interpret continuation tests, recursive base cases, and condition-variable wait loops.

Read how Modern C, Third Edition explains stopping criterion →

Grokking Machine Learning

A criterion that prevents a decision-tree node from being split further.

How it is used
Controls when recursive decision-tree construction should stop to limit overfitting.
How deep it goes
Defines four hyperparameterized conditions but defers their detailed tuning to grid search.
Examples
Uses an app-recommendation dataset whose users are split by age and platform into increasingly pure leaves.
What you can do after
Apply it by setting sample, impurity-improvement, leaf-size, or maximum-depth hyperparameters.

Read how Grokking Machine Learning explains stopping criterion →

Modern C

A controlling expression is an expression whose value determines the path taken by a conditional or other control-flow construct.

How it is used
Uses controlling expressions to select paths, continue loops, terminate recursion, and govern thread waits.
How deep it goes
Explains truth values and evaluation order through worked control-flow examples, while deferring the full set of expression primitives.
Examples
Uses an if assignment, a five-iteration loop, a recursive greatest-common-divisor function, and an accounting thread’s waiting loop.
What you can do after
Apply controlling conditions to trace branches and loops, identify recursive termination checks, and recheck expressions after thread waits.

Read how Modern C explains stopping criterion →

Grokking Algorithms, Second Edition

A base case is the terminating condition of a recursive definition or function that can be solved without another recursive invocation.

How it is used
Stops recursive functions from calling themselves indefinitely and gives divide-and-conquer algorithms a smallest problem to solve directly.
How deep it goes
Defines the base case, traces it in code, and gives a procedure for choosing one; leaves the land-division proof aside.
Examples
Uses a countdown that runs past zero without a return, plus empty and one-element arrays that quicksort returns unchanged.
What you can do after
Build it from scratch in a recursive countdown, then identify direct-return cases when reducing larger problems.

Read how Grokking Algorithms, Second Edition explains stopping criterion →

Grokking AI Algorithms, Second Edition

A stopping condition is a rule that determines when an iterative algorithm terminates.

How it is used
Determines when genetic algorithms, ant colony optimization, and particle swarm optimization stop searching and return a best solution.
How deep it goes
Defines fixed limits, fitness targets, and stagnation checks, with lifecycle explanations and loop implementations.
Examples
Illustrates stopping with ant tours through attractions and a generation-limited genetic algorithm for the knapsack problem.
What you can do after
Apply stopping criteria by choosing an iteration limit, fitness target, or stagnation check suited to the problem and computation budget.

Read how Grokking AI Algorithms, Second Edition explains stopping criterion →

Classic Computer Science Problems in Swift: Essential techniques for practicing programmers

The terminating condition of a recursive algorithm that can be solved directly without another recursive invocation.

How it is used
Prevents infinite recursion by returning directly for inputs that require no further recursive invocation.
How deep it goes
Explains base and recursive cases with Fibonacci and Hanoi, then stops short of formal termination proofs.
Examples
Uses Fibonacci values and one-disc Towers of Hanoi moves as concrete stopping conditions.
What you can do after
Build recursive Swift functions by identifying direct inputs and separating them from recursive cases.

Read how Classic Computer Science Problems in Swift: Essential techniques for practicing programmers explains stopping criterion →

AI Agents in Action, Second Edition

A stop condition is a rule that determines when an iterative agent process must terminate.

How it is used
Controls when research, task, or other iterative agents exit instead of continuing toward a goal.
How deep it goes
Defines a layered termination gate with hard, budget, goal, quality, and stagnation checks, but does not provide complete implementation code.
Examples
Uses iteration caps, token budgets, goal declarations, evaluator scores, semantic-overlap checks, and a MAX_TURNS = 3 planning example.
What you can do after
Operate/configure iterative agents with layered exits, hard ceilings, cost controls, and safeguards against repeated unproductive work.

Read how AI Agents in Action, Second Edition explains stopping criterion →

Get Programming: Learn to code with Python

A Boolean-valued test that determines which execution path a conditional construct should take.

How it is used
Guides conditional choices and controls whether repeated commands run again.
How deep it goes
Explains repeated condition checks, condition updates, and infinite-loop risks, while stopping short of formal debugging methods.
Examples
Uses phone selection, lather-rinse repetition, and a secret-word guessing game to demonstrate conditions and termination.
What you can do after
Build it from scratch by writing conditions that select paths, repeat work, and stop loops at the intended point.

Read how Get Programming: Learn to code with Python explains stopping criterion →

Optimization Algorithms: AI techniques for design, planning, and control problems

A condition that determines when an iterative algorithm should stop.

How it is used
Defines when search, optimization, robotics, genetic, and swarm algorithms finish their iterative work.
How deep it goes
Classifies goal, iteration, quality, stagnation, and resource limits, but does not develop general parameter-selection theory.
Examples
Uses robotic pick-and-place, 7-queens tabu search, genetic algorithm generations, and swarm iterations as concrete cases.
What you can do after
Operate/configure iterative searches by combining iteration, quality, stagnation, and resource limits.

Read how Optimization Algorithms: AI techniques for design, planning, and control problems explains stopping criterion →

Experimentation for Engineers

A stopping rule is a criterion that determines when an experiment or sequential decision process should terminate.

How it is used
Controls when bandit experimentation stops exploring and can promote the currently superior business-metric variant.
How deep it goes
Defines threshold and probability-based rules, explains exploration trade-offs, and accounts for sampling precision and practical significance.
Examples
Uses decaying epsilon with a 0.01 threshold and Thompson sampling with p_stop = 0.95 and minimum per-arm sampling.
What you can do after
Operate/configure bandit experiments by selecting exploration thresholds, tuning exploration duration, and checking minimum-sample requirements.

Read how Experimentation for Engineers explains stopping criterion →

Build a Multi-Agent System (from Scratch)

A stopping condition is a rule that determines when iterative task execution must terminate.

How it is used
Bounds iterative agent task execution, ending it when the task completes or a preset stopping condition is met.
How deep it goes
Shows a maximum-step check and names task completion and irrecoverable errors as endpoints, without detailing other configurable policies.
Examples
Uses a croissant search-and-analysis task and a one-step Hailstone task that ends when its requested step is complete.
What you can do after
Configure task execution with an optional max_steps limit that raises MaxStepsReachedError when reached.

Read how Build a Multi-Agent System (from Scratch) explains stopping criterion →

Build a Reasoning Model (From Scratch)

A criterion that terminates generation when met, such as encountering an end-of-sequence token.

How it is used
Terminates autoregressive text generation when a completion marker or token limit is reached.
How deep it goes
Defines the condition and shows where it breaks the loop, but stops short of broader sampling strategies.
Examples
Uses <|endoftext|>, tokenizer.eos_token_id, and a 100-token prompt run to demonstrate termination.
What you can do after
Operate generation with an EOS-aware loop that stops and streams decoded tokens safely.

Read how Build a Reasoning Model (From Scratch) explains stopping criterion →

100 C++ Mistakes and How to Avoid Them

A base case is the terminating case of a recursive procedure that completes without making another recursive call.

How it is used
Uses a base case to terminate recursive variadic-template processing when one parameter remains.
How deep it goes
Explains how the compiler selects the single-parameter template after recursive calls reduce the remaining parameters.
Examples
Demonstrates a variadic sum with calls using two, three, and four integers.
What you can do after
Build a variadic sum by pairing a single-parameter base case with a recursive template.

Read how 100 C++ Mistakes and How to Avoid Them explains stopping criterion →

Grokking Machine Learning, Second Edition

A rule that determines when a recursive algorithm should stop further processing or subdivision.

How it is used
Controls recursive decision-tree growth to limit overfitting and determine when leaf predictions are finalized.
How deep it goes
Enumerates four practical criteria and their hyperparameters, then embeds them in a step-by-step tree-building procedure.
Examples
Uses pure leaves, sample-count limits, depth limits, and an app-recommendation decision tree to illustrate stopping.
What you can do after
Configure decision-tree growth and determine the majority-label prediction when a split is disallowed.

Read how Grokking Machine Learning, Second Edition explains stopping criterion →

Also covered in

What to know first

Related concepts

Questions about stopping criterion

What is stopping criterion?

A stopping criterion is a condition or rule that determines when a process, computation, or sequence of actions should end.

Which Manning books explain stopping criterion?

Modern C, Third Edition, Grokking Machine Learning, Modern C, Grokking Algorithms, Second Edition, Grokking AI Algorithms, Second Edition, Classic Computer Science Problems in Swift: Essential techniques for practicing programmers, AI Agents in Action, Second Edition, Get Programming: Learn to code with Python and 6 more.

What should I know before learning stopping criterion?

Manning books that teach stopping criterion usually introduce loop, accuracy, function and array first.

What is the difference between stopping criterion and check block?

A stopping criterion is a condition or rule that determines when a process, computation, or sequence of actions should end. A Terraform configuration block that evaluates infrastructure assertions and reports failures without stopping Terraform execution.

What is stopping criterion part of?

Stopping criterion is part of recursion. Recursion is a computational technique in which a definition or procedure refers to or invokes itself, directly or indirectly.

What is stopping criterion also called?

Stopping criterion is also called stopping condition, stop condition, stopping criteria, termination condition or stopping rule.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.