Programming and Data Structures
1
Program Efficiency and Complexity
What will we be looking at:
• What is an "efficient" program?
• How can we measure efficiency?
• The Big O, Big Theta and Big Omega Notation
• Asymtotic Analysis

This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*
Programming and Data Structures
2
Why Measure Efficiency
• Many ways to solve a problem.
- but which way (i.e. algorithm) is better
• Moore’s Law :
- Number of transistors on CPU doubles every year
(well more precisely every 18 months)
- i.e. System performance doubles (well almost) every 18 months
or so.
• If this is so and with current speeds of cpu’s these days, then why
bother worrying about how efficient our code is?

Programming and Data Structures
3
A Classic Optimisation Problem
• Many optimisation problems can be formulated as a Travelling Salesman
problem.
• The Travelling Salesman problem:
- Stated :
“ A travelling salesman has to visit 100 different locations in a town,
what is the shortest route that he can take.”
- Total number of distinct routes possible : 100!
≈
30
100
• What does this mean in turns of running time?
- A supercomputer capable of
checking 100 billion routes per second can
check roughly about 10
20
routes in the space of one year.
- Millions of years needed to check all routes!

This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*