design and analysis of algorithms - kent state...

20
Design and Analysis of Algorithms

Upload: doanxuyen

Post on 27-Jun-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

Design and Analysis of Algorithms

This Class

Website and Contact

Website

I www.cs.kent.edu/∼aleitert/fall15/

I Important information

I Slides

I Announcements

Email

I [email protected]

Feedback

I First time teaching this class.

I Feedback is appreciated.

3 / 19

Primary Textbook

A L G O R I T H M SI N T R O D U C T I O N T O

T H I R D E D I T I O N

T H O M A S H.

C H A R L E S E.

R O N A L D L .

C L I F F O R D S T E I N

R I V E S T

L E I S E R S O N

C O R M E NIntroduction to Algorithms,by Cormen et al.3rd edition, MIT Press, 2009

Primary source for this class.

4 / 19

Other Textbooks

The Algorithm Design Manual,by Steven S. Skiena2nd edition, Springer, 2008

PDF-Version available for free atSpringer Link

5 / 19

Other Textbooks

ptg

Algorithms, 4th Edition,by Robert Sedgewick and Kevin Wayne4th edition, Addison-Wesley Professional, 2011

Algorithm Design: Foundations, Analysis, and InternetExamples,by Michael T. Goodrich and Roberto Tamassia, 1stedition, Wiley, 2001

6 / 19

Clarification

Clarification

You do not need (to buy) a textbook. These are recommendations ifyou are looking for a textbook to study.

7 / 19

Course Requirements

Exam 1 25 % Oct. 8, during classExam 2 25 % Oct. 29, during classExam 3 25 % Nov. 24, during classFinal Exam 25 % Thursday, December 17, 7:45 – 10:00 a.m.

HW (normal) 0 %HW (bonus) 10 %

(Dates may change.)

Exams

I closed book examination

I one handwritten sheet (one side) allowed

8 / 19

Homework

Normal Homework

I Will not be graded.

I Good preparation for exams.

Bonus Homework

I Mostly implementation problems

I Helpful to understand details of algorithms

I Up to 10 % to your final grade.

9 / 19

Office Hours

Tuesday and Thursday, 2.00 – 3.00 p.m.Room 352, Math and CS Building

“I have class during office hours”

I Send me an email. We will find some time.

I Please tell me directly when you have time to meet.

10 / 19

Algorithms

Algorithm

Question

What is an algorithm?

Wikipedia

An algorithm is a self-contained step-by-step set of operations tobe performed. [...] An algorithm is an effective method that canbe expressed within a finite amount of space and time [...] forcalculating a function. Starting from an initial state and initialinput, the instructions describe a computation that [...] proceedsthrough a finite number of well-defined successive states,eventually producing “output” and terminating at a final endingstate.

12 / 19

Algorithm

Question

What is an algorithm?

Wikipedia

An algorithm is a self-contained step-by-step set of operations tobe performed. [...] An algorithm is an effective method that canbe expressed within a finite amount of space and time [...] forcalculating a function. Starting from an initial state and initialinput, the instructions describe a computation that [...] proceedsthrough a finite number of well-defined successive states,eventually producing “output” and terminating at a final endingstate.

12 / 19

Algorithm

Algorithm

An algorithm is a finite and well-defined set of operations which computean output for a (possible empty) input.

AlgorithmInput Output

13 / 19

Properties of Algorithms

Correctness

I Will it produce the desired output?

I We will prove that our algorithms are correct.

Efficiency

I How fast is the algorithm?

I How much resources does it need?

I Is there a faster algorithm?

Having one of both properties is (usually) easy. However, having both isthe goal.

14 / 19

Example

Problem

Finding doubles

You have given two integer arrays A and B. Is there an integer i which isin both arrays?

16 / 19

Algorithm 1

1 For Each a ∈ A

2 For Each b ∈ B

3 If a = b Then

4 Return “Yes”

5 Return “No”

17 / 19

Algorithm 2

1 Sort A and B.

2 Set i := 0 and j := 0.

3 While i < |A| and j < |B|

4 If A[i] = B[j] Then

5 Return “Yes”

6 Else If A[i] < B[j] Then

7 Set i := i + 1.

8 Else If A[i] > B[j] Then

9 Set j := j + 1.

10 Return “No”

18 / 19

Question

Question

Which algorithm is better and why?

19 / 19