1. Algorithms
What Is An Algorithm?
Simply put, an algorithm is a series of
instructions (a procedure) that solves a
problem by using a finite number of steps.
A Computer Scientist would more
accurately describe an algorithm as an
effective method expressed as a finite
list of well-defined instructions for
calculating a function. Starting from an
initial state and initial input the instructions
describe a computation that, when
executed, will proceed through a finite
Source: Wikipedia number of well-defined successive states,
Source: eventually producing output and
http://en.wikipedia.org/wiki/
Algorithm
terminating at a final ending state.
(Phew)!
Information Technology ITaCS and Computer Science
2. Algorithms: Example 1
Food Recipe
A food recipe is a step-by-step procedure
– like a list of instructions - to complete a
task.
A food recipe therefore is like an algorithm.
In this analogy it can be compared to the
software in a system. The hardware is the
oven and the other cooking utensils.
The input is the ingredients and the output
is the cake.
Source: Wikipedia
Information Technology ITaCS and Computer Science
3. Algorithms: Example 2
―Get To School‖
1. Walk to bus 1. Get in car Designing algorithms is about designing
stop 2. Be driven solutions to solve problems.
2. Wait for bus along City If you were to design an algorithm to solve
No.123 Road the problem of ‗getting to school‘ you
3. Get on bus 3. Turn left into would be able to solve this problem in
4. Ride bus to Town Lane several different ways (see left).
school 4. Car stops in Different algorithms can solve the same
5. Get off bus at drop off zone problem – but in different ways.
school bus 5. Get out of car Algorithms that solve the same problem
stop 6. Walk to class may differ in length, efficiency and cost.
6. Walk to class In computer programming there are many
different ways - algorithms - of solving a
For more examples visit : problem and completing a task.
http://computer.howstuffworks.com/ques A computer program can be viewed as an
tion717.htm elaborate algorithm.
Information Technology ITaCS and Computer Science
4. Algorithms: Flowcharts
…making your thinking ‗visible‘
Lamp does
not work Developing a flowchart helps to formalise
the algorithm – and allows more choices,
complexity and variables - crucial as you
Lamp No move past the simplest of algorithms.
Plug in
plugged
lamp
Simple problems can often be shown best
in? as a flowchart.
Yes
Flowcharts can help you to think logically
about problems by working through each
Yes step.
Bulb Replace
‘blown’? bulb
Flowcharts can help you explain your work
to others – and they can follow your
thinking (very useful when trying to ‗fault
No
What other steps
find‘ errors /mistakes‘ in your algorithms).
Repair could be included in
lamp this example?
Information Technology ITaCS and Computer Science
5. Algorithms: Flowcharts
A Guide to understanding flow charts
Source: xkcd.com/518/
http://www.cs.nyu.edu/~acase/classes/spring11/intropr
og/handouts/notes/class5.pdf stion717.htm
Information Technology ITaCS and Computer Science
6. Algorithms: Pseudocode
….like ‗real‘ code
1.. If student's grade is greater than or Computer languages need the correct
equal to 60 syntax or they do not work properly.
Print "passed" Pseudocode has no real syntax rules
else because it is not real computer code – it is
Print "failed" a natural language that is close to
‗computer ‗language.
2. Set total to zero The benefit of pseudocode is that it
Set grade counter to one enables the programmer to concentrate on
While grade counter is less than or the algorithms without worrying about all
equal to ten the syntax which is specific to a particular
Input the next grade programming language. You can even
Add the grade into the total write pseudocode without knowing what
Set the class average to the total programming language you will use for the
divided by ten solution – and others could take your code
Print the class average. but use it with a different language!
Information Technology ITaCS and Computer Science
7. Algorithms On The Internet (1)
PageRank
PageRank is a famous algorithm used by
the Google Internet search engine, that
assigns a numeric value that represents
how important a page is on the web. When
one page links to another page, it is
effectively casting a vote for the other
page. The more votes that are cast for a
page, the more important (in theory) the
page must be. PageRank is Google's way
of deciding a page's importance. It matters
because it is one of the factors that
determines a page's ranking in the search
Cartoon representation of PageRank.
Source Wikipedia: results. It isn't the only factor that Google
http://en.wikipedia.org/wiki/PageRank uses to rank pages, but it is an important
one.
Information Technology ITaCS and Computer Science
8. Algorithms On The Internet (2)
EdgeRank / Amazon / Facebook
EdgeRank is an algorithm developed by
Facebook to govern what is displayed—
and how high—on each users News Feed.
Amazon uses a number of algorithms. The
popularity list algorithm is the accumulated
sales of a book‘s last 30 days compared to
those in its category–but free books given
away only count for roughly 10% of a paid
sale, and price is factored in as well, in that
the higher your price, the more each sale
counts for on the list. Formula:
(sales + (0.1 x free downloads)) x
(unknown sales factor) / last 30 days.
Youtube uses a number of modified
Amazon algorithms.
Information Technology ITaCS and Computer Science
9. Algorithms In The News (1)
‗Right Place Right Time‘
Image: Cutegeek.com
Picture yourself in an expensive designer
clothes shop.
Your smartphone knows where you are –
(thanks to the GPS) - and it alerts your
bank through an automated system that
you've signed up to.
Knowing you've got a history of buying
from similar stores, your bank also knows
that you're running a bit low on cash.
Your phone beeps. A text message. Buy it
in the next 20 minutes and you can borrow
the money at a good rate. Also you'll get
Research: Find out more about this type of 20% off the clothes.
algorithm: You make the purchase – thanks in part to
http://www.bbc.co.uk/news/business-19286426
a ‗right place, right time‘ algorithm.
Information Technology ITaCS and Computer Science
10. Algorithms In The News (2)
Google Algorithms Sued
Bettina Wulff - the wife of a former German
Image source: http://pulse2.com
president has filed a lawsuit against
Google to remove autocomplete
suggestions that she is claiming as
libel. Some of the suggestions that pop-up
when searching for Bettina include the
words ―prostitute‖ and ―red light‖.
Head of PR for Google Germany, Kay
Oberbeck, said the site's search terms
were "algorithmically generated" and
"include the popularity of the entered
search terms".
"All terms that appear have been
Debate: Can the Google algorithm be manipulated? previously entered by Google users," he
What problems may a case like this cause for
Google? added in a statement.
Information Technology ITaCS and Computer Science
Notas do Editor
Flow chart of an algorithm (Euclid's algorithm) for calculating the greatest common divisor (g.c.d.) of two numbers a and b in locations named A and B. The algorithm proceeds by successive subtractions in two loops: IF the test B ≥ A yields "yes" (or true) (more accurately the numberb in location B is greater than or equal to the numbera in location A) THEN the algorithm specifies B ← B − A (meaning the number b − a replaces the old b). Similarly IF A > B THEN A ← A − B. The process terminates when (the contents of) B is 0, yielding the g.c.d. in A. (Algorithm derived from Scott 2009:13; symbols and drawing style from Tausworthe 1977).Source: http://en.wikipedia.org/wiki/AlgorithmiTaCS is an occasional set of resources to support the study of Information Technology and Computer Science and are free to use. iTABs and the iTABs idea are weekly published resources, reflecting ICT, IT and CS news stories with supporting activities to support the teaching of ICT, IT and CS. For a free sample of our back-catalogue Please contact ictcpd1@gmail.com
Image and analogy idea: ediblealgorithms.com/iTaCS is an occasional set of resources to support the study of Information Technology and Computer Science and are free to use. iTABs and the iTABs idea are weekly published resources, reflecting ICT, IT and CS news stories with supporting activities to support the teaching of ICT, IT and CS. For a free sample of our back-catalogue Please contact ictcpd1@gmail.com
iTaCS is an occasional set of resources to support the study of Information Technology and Computer Science and are free to use. iTABs and the iTABs idea are weekly published resources, reflecting ICT, IT and CS news stories with supporting activities to support the teaching of ICT, IT and CS. For a free sample of our back-catalogue Please contact ictcpd1@gmail.com
iTaCS is an occasional set of resources to support the study of Information Technology and Computer Science and are free to use. iTABs and the iTABs idea are weekly published resources, reflecting ICT, IT and CS news stories with supporting activities to support the teaching of ICT, IT and CS. For a free sample of our back-catalogue Please contact ictcpd1@gmail.com
iTaCS is an occasional set of resources to support the study of Information Technology and Computer Science and are free to use. iTABs and the iTABs idea are weekly published resources, reflecting ICT, IT and CS news stories with supporting activities to support the teaching of ICT, IT and CS. For a free sample of our back-catalogue Please contact ictcpd1@gmail.com
iTaCS is an occasional set of resources to support the study of Information Technology and Computer Science and are free to use. iTABs and the iTABs idea are weekly published resources, reflecting ICT, IT and CS news stories with supporting activities to support the teaching of ICT, IT and CS. For a free sample of our back-catalogue please contact ictcpd1@gmail.com
iTaCS is an occasional set of resources to support the study of Information Technology and Computer Science and are free to use. iTABs and the iTABs idea are weekly published resources, reflecting ICT, IT and CS news stories with supporting activities to support the teaching of ICT, IT and CS. For a free sample of our back-catalogue please contact ictcpd1@gmail.com
iTaCS is an occasional set of resources to support the study of Information Technology and Computer Science and are free to use. iTABs and the iTABs idea are weekly published resources, reflecting ICT, IT and CS news stories with supporting activities to support the teaching of ICT, IT and CS. For a free sample of our back-catalogue please contact ictcpd1@gmail.com