What is algorithms
Algorithm as Pseudo Code
Inventing an Algorithm
Iterative vs Recursive
Efficiency
presentaton slides (26 slides)
Staffs in the department whose research are related to algorithms
Previous lecture 2012 hardware
An algorithm is an ordered set of unambiguous, executable steps that defines a terminating process.
The Euclidean algorithm finds the greatest common divisor of two positive
integers X and Y by the following process:
As long as the value of neither X nor Y is zero, continue dividing
the larger of the values by the smaller and assigning X and Y the values
of the divisor and remainder, respectively. (The final value of X is the
greatest common divisor.)
To make it easier to use, we can write it in "pseudocode" (the one without details syntax or data structure operation of a computer language). Assume x > y
function gcd(x, y)
while y ≠ 0
t = y
y = x mod t
x = t
return x
function search( list, target )
if list is empty return NO
else
pick the first entry in the list to be x
while x not-equal target and there is still item in the list
pick the next entry to be x
if x equals target return YES
else return NO
function bsearch ( list, start, end, target )
mid = (start + end) / 2 ****
if target equals list[mid] return YES
else
if start > end return NO
else
if target < list[mid] return bsearch( list, start, mid,
target )
else return bsearch( list, mid+1, end, target)
Move the pivot entry to a temporary location leaving a
hole in List
while (there is a name above the hole and that name is greater than the
pivot) do
(move the name above the hole down into
the hole leaving a hole above the name)
Move the pivot entry into the hole in List.