algorithms and running time

28
Algorithms and Running Time Algorithm: Well defined and finite sequence of steps to solve a well defined problem. Eg.,, Sequence of steps to multiply two numbers. Algorithms are meant to solve all instances of problems for which they are designed. Proof of correctness is important for any algorithm. Another aspect is Running Time. Running time is the number of machine instructions it executes when an algorithm is run on a particular instance. Proof of correctness + Running Time = Analysis of Algorithm.

Upload: connor

Post on 16-Jan-2016

32 views

Category:

Documents


0 download

DESCRIPTION

Algorithms and Running Time Algorithm: Well defined and finite sequence of steps to solve a well defined problem. Eg.,, Sequence of steps to multiply two numbers. Algorithms are meant to solve all instances of problems for which they are designed. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Algorithms and  Running Time

Algorithms and Running Time

Algorithm: Well defined and finite sequence of steps to solve a

well defined problem. Eg.,, Sequence of steps to multiply two numbers.

Algorithms are meant to solve all instances of problems for which

they are designed.

Proof of correctness is important for any algorithm.

Another aspect is Running Time.

Running time is the number of machine instructions it executes

when an algorithm is run on a particular instance.

Proof of correctness + Running Time = Analysis of Algorithm.

Page 2: Algorithms and  Running Time

Running Time of an AlgorithmAlgorithms behavior to any instance of the problem

Two rules are necessary

Running be given for the worst instance of time.

Make running time depend on the size of the instance being solved.

Running time is a function.

The Running time of an algorithm A is 5N2 + 3n + 72 Where n measures the problem size RT of A becomes O(n2) Big O notation is used to show we are dropping lower order terms.

Algorithms whjich run on O(n) are said to be linear time, While that on O(n2) are quadratic.

An algotrithm running as polynomial on n is more efficient than that running as 2n.

Page 3: Algorithms and  Running Time

Classification of ProblemsEfficient Algorithms Exist

Belong to Class P

Easy to Solve Problems

Efficient Algorithms do not Exist

We do not know whether efficient algorithm exist or not. It is undecided

i.e. Have not found an efficient algorithm nor do we know if they exist

NP Complete problems: If a solution is found one can check if it runs on polynomial time.

Easy to Check Problems

NP Hard Problems:P and NP problems are Decision Problems.

HPP is a Decision Problem..

Some are optimization Problems. The TSA is a optimization problem.

The decision version of TSA is NP complete, so the optimization version of TSA is NP hard.

Page 4: Algorithms and  Running Time

GraphsDescribed by two sets

V the set of nodes or vertices

E set of edges

A distinct pairs of vertices Graph G is denoted by

G = (V,E) vertices by u,v or w.

Edges by e or pairs of vertices (u,v)

V = {1, 2, 3, 4}E = { (1, 2),(2, 4),(4,2) (4,1)}

Page 5: Algorithms and  Running Time

Definitions

Undirected graphs: Edge is unordered pair of vertices [(u,v) = (v,u)]

Directed graph: Edge is an ordered pair of vertices [(u,v) ≠(v,u)]

Path is a list of distinct vertices

A cycle is a path such that it travels and no edge is repeated.

Weighted Graph: We associate a real number with edge. The weight of an edge (u,v) is called it’s cost Distance between u,v.

3, 4}E

Page 6: Algorithms and  Running Time

Problems with GraphsHamiltonian Path Problem

Given a directed or undirected graph find:

A cycle in the graph such that every vertex appears exactly once (except first and last vertex).

If this is done we have a Hamiltonian Path.

Traveling salesman problem: Some cities are modeled as vertices and roads as edges. Traveling salesman are interested in minimizing the distance when visiting the cities.

Page 7: Algorithms and  Running Time

Hamiltonian PathGiven a graph G, does there exist a closed path through the graph that visits each vertex once and only once?

Allowed traversal

Allowed traversal

Allowed traversal

Page 8: Algorithms and  Running Time

Forbidden Traversal, since the circled vertices are not visited. The horizontal and vertical mirror images of this traversal are also forbidden (first and second forbiddentraversals).

Forbidden Traversal, since the circled vertices are not visited. The horizontal and vertical mirror images of this traversals are also forbidden (third and fourth forbidden traversals).

Page 9: Algorithms and  Running Time
Page 10: Algorithms and  Running Time
Page 11: Algorithms and  Running Time
Page 12: Algorithms and  Running Time
Page 13: Algorithms and  Running Time

List of resourceswww.usc.edu/dept/molecular-science Leon Adelman (The man who

started it all)

www.dna.caltech.edu/~winfree Links to GOOD reviews

seemanlab4.chem.nyu.edu DNA nanotechnology

How to solve it by Computer R. Dromley, Prentice Hall India.

Page 14: Algorithms and  Running Time

Computing with DNA

The Hamiltonian Path Problem

Introduction

Watson Crick Pairing

Polymerases

Ligases

Gel Electrophoresis

DNA Synthesis

Page 15: Algorithms and  Running Time

Why DNA Computing for the Hamiltonian Problem

1 Algorithmically it is now Clear that one needs massive Parallelism to solve HPP.

2 DNA Computing Represents Massive Parallelism.

3 It has been Calculated that DNA can Hold 1bit/nm3

while Silicon Based Computers can Hold 1bit/µm3.

Page 16: Algorithms and  Running Time

DNA Represents Massive Parallelism

•For a piece of DNA with a length of 20 bases.1ml of 0.001 M solution will contain 1017 molecules.

•Suppose we make a 1015 strands having different base sequences (100 copies of each sequence in solution)

•Introduction 1ml of 0.001 M and among these there are 1014 strands with 1000 copies each.•104 are sequences which are complements to the earlier strands and 1010

are not.These will hybridize with the original strand in an extremely parallel fashion.

•We will find 104 different sequences with 100 copies each

Page 17: Algorithms and  Running Time
Page 18: Algorithms and  Running Time

The AlgorithmGiven a graph with n vertices

• Generate a set of random paths through the graph

• For each path in the set:

• Check whether it starts from start vertex and ends with end vertex; if not remove that path from the set.

• Check it that path through exactly n vertices, it not remove that path from the set.

• For each vertex, check if the path passes through the vertex. It not remove that path from the set.

• If the set is not empty Report a Hamiltonian path

• If the set is Empty Report that there is No Hamiltonian Path.

Page 19: Algorithms and  Running Time

1 Generate a Pool of Random Paths

Synthesize: Complementary DNA City Names (1014 molecules) and DNA flight Numbers (1014 molecules)

Take these, put it together with ligase in about 1 second. One has the answer

Randomly A--B: GCAGTCGG meets Boston Complementary DNA AGCCTGAC by design the A-B sequence ends with TCGG and sequence starts with AGCC.

G C A G T C G G

A G C C T G A C

Page 20: Algorithms and  Running Time

A G C C T G A C

G C A G T C G G

Boston*

Atlanta - Boston

T G A A C G T C A G C C T G A C

G C A G T C G G A C T G G G C T

Atlanta* Boston*

Boston - Chicago

Page 21: Algorithms and  Running Time

T G A A C G T C A G C C T G A C C C G A T A C A

G C A G T C G G A C T G G G C T A T G T C C G A

Atlanta* Boston* Detroit*

Atlanta - Boston - Chicago - Detroit

Page 22: Algorithms and  Running Time

Paths Remaining

1. A-B2. B-A3. B-D4. B-C5. A-D6. C-D7. A-B-C8. A-B-D9. B-C-D10. B-A-D11. A-B-C-D12. A-B-A-D

After I Step in the Algorithm

Page 23: Algorithms and  Running Time

After II Step of the Algorithm

Paths Left out are:

1. A-D2. A-B-D3. A-B-C-D4. A-B-A-D

Page 24: Algorithms and  Running Time

After III Step Of the AlgorithmPaths Left are:

1. A-B-C-D2. A-B-A-D

Page 25: Algorithms and  Running Time

After the Last Step in theAlgorithm

1. A-B-C-D

Page 26: Algorithms and  Running Time

Deterministic & Non-Deterministic Algorithms Deterministic Algorithms are ones when the

Next Step is Fully Defined : Is x a Multiple of y ?

Non Deterministic Algorithms have Steps that Branch out in Several Directions.

When one goes through A-B or A-D one has to Guess as Well as Split.

Computers based on Molecules Mimic both Guessing & Splitting.

Page 27: Algorithms and  Running Time
Page 28: Algorithms and  Running Time

The Future of Computing