0% found this document useful (0 votes)
45 views

Algorithms: Professor: Roberto Aburto

This document defines algorithms and provides examples. It states that an algorithm is a step-by-step method for solving a problem, deriving from the name of mathematician Al-Khwārizmī. Algorithms have characteristics like inputs, outputs, precision, determinism, and finiteness. The document gives two examples: an algorithm to find the maximum of three numbers, and an algorithm to find the maximum value in a sequence. It provides pseudocode to demonstrate how each algorithm works step-by-step.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Algorithms: Professor: Roberto Aburto

This document defines algorithms and provides examples. It states that an algorithm is a step-by-step method for solving a problem, deriving from the name of mathematician Al-Khwārizmī. Algorithms have characteristics like inputs, outputs, precision, determinism, and finiteness. The document gives two examples: an algorithm to find the maximum of three numbers, and an algorithm to find the maximum value in a sequence. It provides pseudocode to demonstrate how each algorithm works step-by-step.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

ALGORITHMS

Professor: Roberto Aburto


Definition
An algorithm is an step by
step method of solving some
problem.
This approach to problem
solving derives from the name
of the ninth-century Persian
mathematician Al-Khwrizm.
Nowadays, Algorithm refers to
a solution that can be
executed by a computer.
Introduction
Algorithms typically have the following characteristics:
Input: the algorithm receives input.
Output: The algorithm produces output.
Precision: The steps are precisely stated.
Determinism: the intermediate results of each step of
execution are unique and are determined only by the
inputs and the results of the preceding steps.
Finiteness: The algorithm terminates; that is, it stops after
finitely many instructions have been executed
Introduction
Correctness: The output produced by the algorithm is
correct; that is, the algorithm correctly solves the
problem.
Generality: the algorithm applies to a set of inputs.
Example
Consider the following algorithm that finds
the maximum of three numbers a, b, and c:
1. = .
2. If b>large, then large=b.
3. If c>large, then large=c.
Finding the Maximum of Three Numbers.
This algorithm finds the largest of the numbers a, b, and c.
Input: a, b, c
Output: large (the largest of a, b, and c)
1. max3(a, b, c) {
2. arge= a
3. If (b> large) // if b is larger than large, update large
4. large= b
5. If (c> large) // if c is larger than large, update large
6. large= c
7. Return large
8. }
Finding the Maximum Value in a Sequence
The algorithm finds the largest of the numbers 1 , 2 , ,
Inputs: s, n
Output: large (the largest value in a sequence s)
max(s, n) {
large= 1
for i= 2 to n
If ( > )
large=
return large
}
Thanks
References
Johnsonbaugh, Richard. Discrete
mathematics. Pearson/Prentice Hall, 2014.

You might also like