2. 2
Algorithm
Logical steps to solve a problem, that’s it!
A process or set of rules to be followed in
calculations or other problem-solving
operations, especially by a computer.
A finite sequence of well-defined,
computer-implementable instructions,
typically to solve a class of specific
problems or to perform a computation.
3. 3
Algorithm
Sample problem
Find the largest number in a list of numbers of
random order
39, 7, 68, 55, 3
Algorithm
Assume the first number in the set is the largest
number in the set.
For each remaining number in the set: if this number is
larger than the current largest number, consider this
number to be the largest number in the set.
When there are no numbers left in the set to iterate
over, consider the current largest number to be the
largest number of the set.
6. 6
Pseudo Code
A bridge between algorithm and actual coding
Input: A list of numbers a[N]
largest = a[0]
for each item in a, do
if item > largest, then largest = item
Output: The largest number in the list a[N]
7. 7
General Steps in Programming in Physics
Find a (physical) problem!
Describe the problem with mathematical
modeling (get the equations)
Make an algorithm to solve the problem
Make a flowchart
Make a pseudo code
Develop the computer program