Top Banner
Design and Analysis of Algorithms
20

Design and Analysis of Algorithms - Kent State Universityaleitert/fall15/slides/00Introduction.pdf · Design and Analysis of Algorithms. This Class. ... Introduction to Algorithms,

Jun 27, 2018

Download

Documents

doanxuyen
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Design and Analysis of Algorithms - Kent State Universityaleitert/fall15/slides/00Introduction.pdf · Design and Analysis of Algorithms. This Class. ... Introduction to Algorithms,

Design and Analysis of Algorithms

Page 2: Design and Analysis of Algorithms - Kent State Universityaleitert/fall15/slides/00Introduction.pdf · Design and Analysis of Algorithms. This Class. ... Introduction to Algorithms,

This Class

Page 3: Design and Analysis of Algorithms - Kent State Universityaleitert/fall15/slides/00Introduction.pdf · Design and Analysis of Algorithms. This Class. ... Introduction to Algorithms,

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

Page 4: Design and Analysis of Algorithms - Kent State Universityaleitert/fall15/slides/00Introduction.pdf · Design and Analysis of Algorithms. This Class. ... Introduction to Algorithms,

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

Page 5: Design and Analysis of Algorithms - Kent State Universityaleitert/fall15/slides/00Introduction.pdf · Design and Analysis of Algorithms. This Class. ... Introduction to Algorithms,

Other Textbooks

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

PDF-Version available for free atSpringer Link

5 / 19

Page 6: Design and Analysis of Algorithms - Kent State Universityaleitert/fall15/slides/00Introduction.pdf · Design and Analysis of Algorithms. This Class. ... Introduction to Algorithms,

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

Page 7: Design and Analysis of Algorithms - Kent State Universityaleitert/fall15/slides/00Introduction.pdf · Design and Analysis of Algorithms. This Class. ... Introduction to Algorithms,

Clarification

Clarification

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

7 / 19

Page 8: Design and Analysis of Algorithms - Kent State Universityaleitert/fall15/slides/00Introduction.pdf · Design and Analysis of Algorithms. This Class. ... Introduction to Algorithms,

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

Page 9: Design and Analysis of Algorithms - Kent State Universityaleitert/fall15/slides/00Introduction.pdf · Design and Analysis of Algorithms. This Class. ... Introduction to Algorithms,

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

Page 10: Design and Analysis of Algorithms - Kent State Universityaleitert/fall15/slides/00Introduction.pdf · Design and Analysis of Algorithms. This Class. ... Introduction to Algorithms,

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

Page 11: Design and Analysis of Algorithms - Kent State Universityaleitert/fall15/slides/00Introduction.pdf · Design and Analysis of Algorithms. This Class. ... Introduction to Algorithms,

Algorithms

Page 12: Design and Analysis of Algorithms - Kent State Universityaleitert/fall15/slides/00Introduction.pdf · Design and Analysis of Algorithms. This Class. ... Introduction to 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

Page 13: Design and Analysis of Algorithms - Kent State Universityaleitert/fall15/slides/00Introduction.pdf · Design and Analysis of Algorithms. This Class. ... Introduction to 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

Page 14: Design and Analysis of Algorithms - Kent State Universityaleitert/fall15/slides/00Introduction.pdf · Design and Analysis of Algorithms. This Class. ... Introduction to Algorithms,

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

Page 15: Design and Analysis of Algorithms - Kent State Universityaleitert/fall15/slides/00Introduction.pdf · Design and Analysis of Algorithms. This Class. ... Introduction to Algorithms,

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

Page 16: Design and Analysis of Algorithms - Kent State Universityaleitert/fall15/slides/00Introduction.pdf · Design and Analysis of Algorithms. This Class. ... Introduction to Algorithms,

Example

Page 17: Design and Analysis of Algorithms - Kent State Universityaleitert/fall15/slides/00Introduction.pdf · Design and Analysis of Algorithms. This Class. ... Introduction to Algorithms,

Problem

Finding doubles

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

16 / 19

Page 18: Design and Analysis of Algorithms - Kent State Universityaleitert/fall15/slides/00Introduction.pdf · Design and Analysis of Algorithms. This Class. ... Introduction to Algorithms,

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

Page 19: Design and Analysis of Algorithms - Kent State Universityaleitert/fall15/slides/00Introduction.pdf · Design and Analysis of Algorithms. This Class. ... Introduction to Algorithms,

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

Page 20: Design and Analysis of Algorithms - Kent State Universityaleitert/fall15/slides/00Introduction.pdf · Design and Analysis of Algorithms. This Class. ... Introduction to Algorithms,

Question

Question

Which algorithm is better and why?

19 / 19