CS300-01_Algorithm_Analysis - Algorithm Analysis Sung Yong...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Algorithm Analysis Sung Yong Shin CS Dept. KAIST
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Outline 1. Introduction 2. Analyzing Algorithms and Problems 3. Asymptotic Growth Rate
Background image of page 2
3 1. Introduction Definition : ( Algorithm ) An algorithm is a finite sequence of instructions, if followed, to accomplish a particular task Five characteristics of an algorithm Input : Zero or more quantities (data) are supplied externally Output : At least one quantity (data) is produced Definiteness : Each instruction must be clear and unambiguous Finiteness : An algorithm is required to terminate after a finite number of steps Effectiveness : Every instruction must be sufficiently basic so that anyone can follow Input Output
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The characterization of a solution of a problem S is a solution of problem A if and only if S satisfies property C C is said to be the characterization of a solution. 4 Good algorithm Good characterization Why ? (What dose it mean by “good” ?) Is its converse true ? Well, . ..... Seemingly not but nobody knows !!! S is a solution S satisfies C ) ( NP P
Background image of page 4
5 Algorithm description languages pidgin ALGOL FORGOL Java Unambiguous Independent of computers Easy to translate into a computer language
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 2. Analyzing Algorithms and Problems Correctness Efficiency Amount of work done (time complexities) Amount of space used (space complexities) Optimality Simplicity (clarity)
Background image of page 6
7 Correctness Precise problem statement: What inputs to work on What results to produce Solution method Implementation A sequence of instructions for carrying it out Input Output
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 How to Prove Correctness Loop invariants Program structure Definition: (Loop invariant) Loop invariants are conditions and relationships that are satisfied by the variables and data structures at the end(beginning) of each iteration of the loop. Establish loop invariants by mathematical induction !! Loop
Background image of page 8
9 Example Given an array L containing n elements ( n 0 ) and a number x , find the index of the first occurrence of x in L , if x is in L , and report 0 otherwise. What is input? L and x What is output ? If x L , the index of the first occurrence of x Otherwise, 0 Algorithm 1. index := 1 ; 2. while index n and L(index) x do 3. index := index + 1 4. end {while} 5. if index n , then index := 0 end; Sequential search !!!
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
[Proof] By induction Obvious Suppose that index = k and L ( i ) x for 1 i < k when line 2 is executed k times for some 1 k < n
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 28

CS300-01_Algorithm_Analysis - Algorithm Analysis Sung Yong...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online