This document provides an overview of algorithms and problem solving. It defines an algorithm as an explicit step-by-step procedure to solve a problem or achieve a goal. Algorithms can be expressed mathematically but are not necessarily mathematical operations. Effective algorithms have clear initial and terminal conditions. Algorithms are related to mathematical statements by expressing problems as functions and writing step-by-step instructions. Computers require algorithms to apply their calculation abilities to practical tasks, as they are otherwise unable to solve problems without explicit instructions. Pseudocode is introduced as a way to describe algorithms without syntax of a specific programming language.
3. Outline
– Algorithm
– What is an algorithm?
– How are mathematical statements and algorithms
related?
– What do algorithms have to do with computers?
– Pseudo Code
– What is pseudocode?
– Writing pseudocode
– Pseudo Code vs Algorithm
4. What is an algorithm?
–An algorithm is a finite, explicit step-by-step procedure for solving a specific problem
or accomplishing a specific goal.
–We frequently talk about algorithms in mathematical terms, and many algorithms are
expressed using notation borrowed from mathematics, but algorithms aren't
necessarily mathematical in the operations performed, or in the results produced.
– In general, an effective algorithm has these characteristics:
– Explicit, complete, and precise initial conditions;
– A finite, complete, unbroken
– Explicit, complete, and precise terminal (stopping) conditions
6. How are mathematical statements
and algorithms related?
5(𝐹− 32) = 9
𝐶
– First, convert expression into a form that expresses C as a function of F:
C=5/9 * (F – 32)
– Now it's a straightforward task to write an algorithm (based on the standard
order
of arithmetic operations) to convert from Fahrenheit to Celsius.
– Start with a given temperature in degrees Fahrenheit.
– Subtract 32 from the value used in step # 1.
– Multiply the result of step # 2 by 5.
– Divide the result of step # 3 by 9.
– The result of step # 4 is the temperature in degrees Celsius.
7. What do algorithms have to do
with computers?
– Computer programming consists, in large part, of creating unambiguous, step-by-step
procedures for the computer to follow, to produce specific results. In other words, we
might say that computer programming is almost all about algorithms.
– In many respects, computers are electronic idiot savants: they can perform amazing
feats of calculation and memory, but without our help, they're almost totally
incompetent when it comes to applying those abilities to practical problems.
– Want to compute the sine of an angle? How about computing the natural logarithm of a
number? These tasks are easy for a computer –, in most modern computers, these
operations are built into the CPU itself.
– But if you want to plot the graph of y=sin x on the screen, or balance your cheque
book, or compute the area of the region 1≤x≤100,0≤y≤1/x, the computer is helpless –
until someone writes algorithms to accomplish these tasks, and “teaches” them to the
computer.