Skip to content
Home Ā» Exhaustive search

Exhaustive search


šŸ“˜ Exhaustive Search

(Basic Algorithm Design Technique)

1ļøāƒ£ Introduction

Exhaustive Search (also called Brute Force Technique) is the simplest algorithm design strategy.

šŸ”¹ Definition

It involves:

Trying all possible solutions and selecting the one that satisfies the problem constraints.

āœ” No shortcuts
āœ” No assumptions
āœ” Guaranteed to find correct solution


2ļøāƒ£ Basic Idea

  • Generate all possible candidate solutions
  • Test each candidate
  • Select the best or valid solution

3ļøāƒ£ Steps in Exhaustive Search

  1. Generate all possible solutions
  2. Check each solution for feasibility
  3. Keep track of the best solution
  4. Return final result

4ļøāƒ£ Characteristics of Exhaustive Search

āœ” Simple and straightforward
āœ” Always produces optimal solution
āœ” Does not require complex logic
āœ– Highly inefficient for large inputs


5ļøāƒ£ Examples of Exhaustive Search


šŸ”¹ 1. Linear Search

  • Check each element one by one

Time Complexity: O(n)


šŸ”¹ 2. Traveling Salesperson Problem (Brute Force)

  • Check all permutations of cities

Time Complexity: O(n!)


šŸ”¹ 3. Subset Sum Problem

  • Check all subsets

Time Complexity: O(2ⁿ)


šŸ”¹ 4. Selection Sort

  • Find minimum element repeatedly

Time Complexity: O(n²)


6ļøāƒ£ Advantages of Exhaustive Search

āœ” Easy to understand and implement
āœ” Always finds the correct solution
āœ” Useful for small input sizes
āœ” Can be used as a baseline solution


7ļøāƒ£ Disadvantages of Exhaustive Search

āœ– Very high time complexity
āœ– Not scalable for large problems
āœ– Inefficient (redundant computations)