Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Unit 1 — Generate-and-Test

Lesson 10 of 34 in the free Artificial Intelligence notes on Siksha Sarovar, written by Rohit Jangra.

Generate-and-Test

Generate-and-test is the simplest heuristic search strategy: repeatedly generate a possible solution, then test whether it is actually a solution — keep going until one passes, or the space is exhausted.

Algorithm

1. Generate a possible solution (a point in the problem space, or a path from the initial state)
2. Test the candidate to see if it is actually a solution, by comparing it to the goal
3. If it is a solution, stop and report it
4. Otherwise, go back to step 1 and generate another candidate

Variants

VariantDescription
Exhaustive generate-and-testSystematically generates every possible candidate (a form of blind/brute-force search)
Heuristic generate-and-testUses domain knowledge to generate only plausible candidates, pruning the obviously wrong ones early
Plan-generate-testA plan first constrains the space of candidates to a promising subset before generating and testing within it

Classic Example: Cryptarithmetic (SEND + MORE = MONEY)

Generate an assignment of digits 0–9 to letters S, E, N, D, M, O, R, Y (no leading zero, all letters distinct), then test whether SEND + MORE = MONEY holds arithmetically. Exhaustive generate-and-test over roughly 1.8 million possible assignments is workable by computer but wasteful by hand — a heuristic version prunes using column-wise carry constraints (M must be 1, since two 4-digit numbers summing to a 5-digit number forces a carry into a new digit).

Strengths and Weaknesses

StrengthsWeaknesses
Simple to understand and implementNo memory across attempts — earlier failures don't inform later candidates unless heuristics are added
Works when a good generator + good test are easy to buildExhaustive version is intractable for large spaces (combinatorial explosion)
Good baseline / fallback strategyCan regenerate the same or a very similar wrong candidate repeatedly if not carefully designed

Generate-and-test is the conceptual ancestor of hill climbing and best-first search — both are "smarter" versions that use a heuristic to decide which candidate to generate next, rather than generating blindly.