Modelling Problems and Solutions

How to represent the problem in computer world, and how to represent its solution.

e.g.

Problem: A quadratic equation with one unknown can be represented by an expression:

a*x*x+b*x+c == 0

While its solution can be represented by a number x.

Problem: The chessboard of Eight Queens Problem can be represented by a two dimensional array with [8][8], with a[i][j] == 0 representing no queen and a[i][j]==1 representing a queen on position i,j. While its solution can be represented by a chessboard configuration such that no queen conflict with any other queen.

A General Algoarithm to solve an abstract problem is:

  • 1, set S be a solution space, that is the set of all possible solutions;
  • 2, for every possible solution s in S, 
    • 2.1, check whether s is really a solution of the problem
    • 2.2, if s is a valid solution of the problem, output the solution s;
    • 2.3, if want to find next solution, go to step 2;
  • 3, end.

This is a brute-force strategy for searching all possible solutions in solution space.

prossimple

conslow efficiency 

Examples:

 

You have no rights to post comments