Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Chapter 1

Algorithms

An algorithm is a well-defined computational procedure that takes some value, or set of values as
input and produces some value or set of values as output.

It is a sequence of computational steps that transforms an input to an output.

or

A tool to solve a well-defined computational problem.

Specifies the desired input output relationship

Instance of a problem consists of the input required to compute the solution to the problem. It
satisfies that constraints imposed on it by the problem statement.

An algorithm is correct if for every problem instance it halts with the correct output.

Incorrect algorithm may be useful if we can control the error rate.

What kind of problems are solved by algorithms?

Human genome project

 Identifying the genes in human DNA


 Storing it in database
 Data analysis

All requires algorithms

Internet

For managing and manipulating large volumes of data.

Finding good routes for the data to travel.

Search engines to quickly find relevant pages.

Electronic commerce

Depends on privacy of personal info, using cryptography and numerical signatures which uses algo
and no. theory.

Allocating scarce resources in a optimal way

Assigning crews in airplanes or where to place oil wells in mining industry etc.

The examples above exhibit that Algorithms have 2 main properties

 They have numerous candidate solutions


 They have practical applications

Data structures - A data structure is a way to store data in order to facilitate access and modification

Hard problems

Why are NP problems interesting?


1. No efficient algorithm has been found, and there is no proof that one does not exist.
2. The set of NP problems have a property that if there is an efficient algo for one, then there
exist efficient algos for all.
3. The problem statement for NP-complete problems are similar, not identical, to problems for
which efficient algorithms exist.

Algorithms as a technology

Computing time is a bounded resource and memory is not free. Resource need to be used wisely.

Algorithms must be efficient in terms of time and space.

Efficiency

Different algorithms that solve the same problem may differ dramatically in their efficiency.

Example:
2
Insertion sort takes roughly c 1 n time to sort n items

Merge sort takes roughly c 2 nlog(n) time to sort n items

Typically, c 1 <c 2

Even though insertion sort is faster in smaller input sizes, merge is faster in larger sets because its
advantage of lg n vs . n more than compensates for difference in cost factors.

Algorithms and other technologies

Algorithms, like computer hardware should be considered a technology because system


performance depends on choosing efficient algorithm as much as on fast hardware.

You might also like