1. the role of the algorithms in computer. 2 1.1 algorithms – 1/2 algorithm: any well-defined...

5
1. The Role of the Algorithms in Computer

Upload: florence-snow

Post on 03-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1. The Role of the Algorithms in Computer. 2 1.1 Algorithms – 1/2 Algorithm: Any well-defined computation procedure that takes some value, or set of values,

1. The Role of the Algorithms in Computer

Page 2: 1. The Role of the Algorithms in Computer. 2 1.1 Algorithms – 1/2 Algorithm: Any well-defined computation procedure that takes some value, or set of values,

2

1.1 Algorithms – 1/2 Algorithm: Any well-defined computation

procedure that takes some value, or set of values, as input and produces some value, or set of values, as output.

Or: tool for solving well specific computational problem.

Example: Sorting problem Input: A sequence of n numbers Output: A permutation of the input sequence such that .

a a an1 2, ,...,

a a an1 2' ' ', ,...,

a a an1 2' ' '...

Page 3: 1. The Role of the Algorithms in Computer. 2 1.1 Algorithms – 1/2 Algorithm: Any well-defined computation procedure that takes some value, or set of values,

3

Algorithms – 2/2 An instance of a problem consists of all inputs

needed to compute a solution to the problem. An algorithm is said to be correct if for every

input instance, it halts with the correct output. A correct algorithm solves the given

computational problem. An incorrect algorithm might not halt at all on some input instance, or it might halt with other than the desired answer.

Page 4: 1. The Role of the Algorithms in Computer. 2 1.1 Algorithms – 1/2 Algorithm: Any well-defined computation procedure that takes some value, or set of values,

4

What kind of problem can be solved by algorithm?

The Human Genome Project The Internet Applications Electronic Commerce with Public-key

cryptography and digital signatures Manufacturing and other commercial

settings – linear programming Shorted paths

Page 5: 1. The Role of the Algorithms in Computer. 2 1.1 Algorithms – 1/2 Algorithm: Any well-defined computation procedure that takes some value, or set of values,

5

Efficiency Insertion sort: c1n2

Mergesort c2nlogn c1<c2

Computer A runs 109 instructions/second Computer B runs 107 instructions/second Let c1=2, c2=50,

run Insertion sort on Computer A, andrun mergesort on Computer B

When n = 106, 2000 seconds versus 100 seconds When n = 108, 2.3 days versus 20 minutes