š 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
- Generate all possible solutions
- Check each solution for feasibility
- Keep track of the best solution
- 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)
