02 Algorithms
02 Algorithms
J. Kizito
Makerere University
e-mail: [email protected]
www: https://www.socnetsolutions.com/~jona
materials: https://www.socnetsolutions.com/~jona/materials/CSC1204
e-learning environment: http://muele.mak.ac.ug
office: block A, level 3, department of computer science
alt. office: institute of open, distance, and eLearning
Algorithms Design
1 Algorithm Design
Algorithms
How do we solve problems?
We “just do”
Guesswork-and-luck
Trial-and-error
Experience (possibly someone else’s)
“Scientifically”
Algorithms
The Problem-solving Process (1)
Algorithms
The Problem-solving Process (2)
Algorithm
Definition
Algorithms
Properties of an Algorithm
Algorithms
Components of an Algorithm
Algorithm
1 Set max to 0
2 For each number x in the list L, compare it to max. If x is larger, set max to x
3 max is now set to the largest number in the list
Algorithm
1 Set max to 0
2 For each number x in the list L, compare it to max. If x is larger, set max to x
3 max is now set to the largest number in the list
Algorithm
1 Set max to 0
2 For each number x in the list L, compare it to max. If x is larger, set max to x
3 max is now set to the largest number in the list
More on Algorithms