Week 1
Week 1
Week 1
A. Problem solving is the process of logically breaking down a problem into three major phases
1. Stating clearly what the problem is
2. Defining how the problem can be solved in a logical sequence of steps
3. Verifying that the solution really does solve the stated problem
B. When humans solve problems by themselves, they use a vast array of knowledge and understanding to per-
form these problem solving steps.
C. When humans use a computer to solve a problem, the solution must be coded in a programming language
which, as we noted above, is much simpler than the natural language humans use with one another.
D. Further, if we think of the human and the computer as a problem solving team, the computer is definitely the
junior partner in the team effort; specifically:
1. The human does all of the problem statement phase of problem solving.
2. The human then outlines a solution in the form of an algorithm, which can be thought of as a high-level
program.
3. The human then encodes the algorithm in a computer programming language.
4. The computer compiles (i.e., translates) the program into an electronic form that can be executed directly
by the computer hardware; this form is called the machine code.
5. The computer runs the machine code to produce an answer.
6. The human validates that the answer is correct, but writing testing programs.
languages, and this will figure into our programming discussions throughout quarter.
G. In class, we’ll dissect the algorithm and program to see exactly what’s going on; the dissection will discuss
the following fundamental aspects of a program:
1. Programs have an explicit beginning and ending, that are clearly delineated.
2. Programs use variables to hold data values, such as numbers; these variables are similar to variables used
in mathematical formulas.
3. Programs must define precisely how data values are input (i.e., read in) and output (i.e., printed out).
4. Programming languages have most of the normal forms of arithmetic expressions for adding, multiplying,
comparing, etc.
5. One of the most fundamental constructs in a programming language is the conditional statement, which is
used to define how the program makes decisions.
a. The common syntactic form of a conditional in most programming languages is an "if" statement.
b. It is used above to decide the basic problem here -- whether the number is > 0.
c. Based on the condition (x > 0) in the if statement, the program decides which one of two possible
actions to take.