two integers is another example of the divide and conquer strategy.A divide and conquer problem solving strategy works by recursively breaking down a problem into two or more sub-problems of the same (or related) type, until these become simple enough to be solved directly. The solutions to the sub- problems are then combined to give a solution to the original problem.
Job Assignment Problem Exhaustive Search
Knapsack Problem Exhaustive Search
Problem solving by exhaustive search • Suppose we have a Boolean expression • F(a, b, c) = ab`c` + abc` + ac` • One way of finding all the tuples (a, b, c) that yield true is to try out all the possibilities for the Boolean variables a, b, c. • This gives 2^3 possibilities.
Problem solving by exhaustive search • Suppose we have n variables then we get 2^n possibilities. • This is an example of exhaustive search. • Here the number of searches grows exponentially with n. • Exhaustive search is also known as brute-force search.
Trial and Error Method
Problem solving by trial and error • Suppose we have to factor the polynomial x^2 + 4x + 3. • The original binomials must have looked like this: • (x + m)(x + n), • where m and n are integers.We need to figure out the values of m and n. The constant term of the original polynomial is 3, so we need m*n = 3.
Problem solving by trial and error • What integers multiply together to give 3? The only choices are 1 and 3, or perhaps -1 and -3. • The coefficient of the x term in the original polynomial is 4, so we also need • m + n = 4. • Since 1 and 3 multiply to give 3 and add together to give 4, we have m = 1 and n = 3. Therefore, we can factor our original polynomial as • (x + 1)(x + 3)
Problem solving by trial and error • If we let m = 3 and n = 1 we'll have the same factorization, except with the factors written in a different order. Either way is correct, • The problem was solved by the problem solving strategy of trial and error. Trial and error can be used for solving puzzles such as Sudoku.
Map Coloring Problem
Problem solving by backtracking • Suppose we have to arrange 8 queens in a chess board such that no two queens attack each other.
- Fall '16
- Eight queens puzzle