Tom Kelliher, CS17
Feb. 12, 1996
Observations from the lab:
The process of transforming the description of a problem into the solution of that problem by using our knowledge of the problem domain and by relying on our ability to select and use appropriate problem-solving strategies, techniques, and tools.
A few problems examples:
Also known as the software life cycle
Starting from the problem statement:
Is the life cycle always linear?
Divide-And-Conquer
Details to be determined:
Algorithm:
A sequence of a finite number of steps arranged in a specific logical order which, when executed, produces the solution for a problem.
An algorithm must satisfy the following requirements:
Pseudocode:
A semiformal, English-like language with a limited vocabulary that can be used to design and describe algorithms.
C. Bohm and G. Jacopini proved in 1966 than pseudocode required only three structural elements
A series of steps or statements that are executed in the order they are written in an algorithm.
Example:
print "What is your name?" read name print "How old are you, ", name, "?" read age let birthYear = CURRENT_YEAR - age
begin/ end pair grouping:
begin let amountDue = overDue + currentBilling + penalty print "You owe: ", amountDue end
The alternatives of two courses of action only one of which is taken depending on the outcome of a condition, which is either true or false.
if condition then_part else else_part end_if
Structure of then_part
, else_part
:
if payment is overdue begin let amountDue = pastDue + currentBilling + penalty print "You owe: ", amountDue end else print You owe: , currentBilling end_if
Alternative nested if-else structure element: else_if
if grade < 60 print "F" else_if grade < 70 print "D" else_if grade < 80 print "C" else_if grade < 90 print "B" else print "A" end_if
Specifies a block of one or more statements that are repeatedly executed until a condition is satisfied.
while condition loop_body end_while
Structure of loop_body
let sum = 0 while there are input numbers to sum begin print "Next number: " read number let sum = sum + number end end_while print "The sum is: ", sum