two integers is another example of the divide and conquer strategyA divide and

# Two integers is another example of the divide and

• 38

This preview shows page 20 - 32 out of 38 pages.

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.  #### You've reached the end of your free preview.

Want to read all 38 pages?

• Fall '16
• Jegan
• Eight queens puzzle

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern  