Exhaustive Search
- Exhaustive search means trying every possible combination for an optimal solution.
- IT tends to be very expensive.
- Three examples:
- Traveling Salesperson Problem
- Assume a connected weighted graph.
- What is the lowest cost Hamiltonian circuit of the graph.
- A Hamiltonian circuit visits every vertex, except the first, exactly once.
- Generate all permutations of the verticies.
- Check to see if each is optimal
- This is O(n!)
- Knapsack Problem
- Assume n items
- Each has value vi, 0 < i ≤ n
- Each has weight wi
- And a Knapsack which can hold a total weigh of W.
- Find a subset S of the n items, such that the total weight of the items in S is less than W, with the maximum value.
- Essentially, set up a bit vector, either an item is in (1) or not (0) .
- Evaluate if this vector is
- Under the given weight
- And has maximum value.
- This is O(2n)