Algorithm Analysis Objectives: N, Where C Is Time Taken by
Algorithm Analysis Objectives: N, Where C Is Time Taken by
Objectives
To
understand
why
algorithm analysis is important.
To be able to use BigO to describe execution time.
To understand the BigO execution time of common
operations on Python lists and
dictionaries.
To understand how the
implementation of Python data
impacts algorithm analysis.
To understand how to
benchmark
simple
Python
programs.
What Is Algorithm Analysis?
an algorithm is a generic, stepby-step list of instructions for
solving a problem. It is a method
for solving any instance of the
problem such that given a
particular input, the algorithm
produces the desired result. A
program, on the other hand, is
an algorithm that has been
encoded
into
some
programming language. There
may be many programs for the
same algorithm, depending on
the
programmer
and
the
programming language being
used.
Algorithm
analysis
is
concerned
with
comparing
algorithms based upon the
amount of computing resources
that each algorithm uses. We
want to be able to consider two
algorithms and say that one is
better than the other because it
is more efficient in its use of
those resources or perhaps
because it simply uses fewer.
From this perspective, the two
functions above seem very
similar.
They
both
use
essentially the same algorithm
to
solve
the
summation
problem.
Algorithmic
complexity
is
concerned about how fast or
slow
particular
algorithm
performs. We define complexity
as a numerical function T(n) time versus the input size n. We
want to define time taken by an
algorithm without depending on
the implementation details. But
Problem Definition.
Problem Analysis.
Generating
possible
Solutions.
Analyzing
the
Solutions.
Selecting
the
best
Solution(s).
Planning
the
next
course of action (Next
Steps)
The process is only a guide for
problem solving. It is useful to
have a structure to follow to
make sure that nothing is
overlooked. Nothing here is
likely to be brand new to
anyone, but it is the pure
acknowledgement
and
reminding of the process that
can help the problems to be
solved.
1. Problem Definition
The normal process for solving a
problem will initially involve
defining the problem you want
to solve. You need to decide
what you want achieve and
write it down. Often people keep
the problem in their head as a
vague idea and can so often get
lost in what they are trying to
solve that no solution seems to
fit. Merely writing down the
problem forces you to think
about what you are actually
trying to solve and how much
you want to achieve. The first
part of the process not only
involves
writing
down
the
problem to solve, but also
checking that you are answering
the right problem. It is a checkstep to ensure that you do not
answer a side issue or only
solve the part of the problem
that is most easy to solve.
People often use the most
immediate solution to the first
problem definition that they find
without spending time checking
the problem is the right one to
answer.
2. Problem Analysis
The next step in the process is
often to check where we are,
what is the current situation and
what is involved in making it a
problem. For example, what are
the benefits of the current
product/service/process?
And
why did we decide to make it
like that? Understanding where
An implementation of ADT
consists
of
storage
structures to store the data
items and algorithms for
basic operation
1.
2.
ADT consists of
The collection of data
items
Basic operation that
must be performed on
them
In the example, a
collection of data is a
list of seats
The basic operations
are (1) Scan the list to
determine which seats
are
occupied
(2)
change seats status