19
CAP 5510 / CGS 5166 COT 6405: Analysis of Algorithms Giri NARASIMHAN www.cs.fiu.edu/~giri/teach/6405F19.html 8/26/19 1

COT 6405: Analysis of Algorithmsgiri/teach/6405/f19/Lec/1-intro.pdf · CAP 5510 / CGS 5166 Text 3rd Edition • ISBN-13: 978-8120340077 • ISBN-10: 9788120340077 8/26/19!2

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: COT 6405: Analysis of Algorithmsgiri/teach/6405/f19/Lec/1-intro.pdf · CAP 5510 / CGS 5166 Text 3rd Edition • ISBN-13: 978-8120340077 • ISBN-10: 9788120340077 8/26/19!2

CAP 5510 / CGS 5166

COT 6405: Analysis of AlgorithmsGiri NARASIMHAN

www.cs.fiu.edu/~giri/teach/6405F19.html 8/26/19

!1

Page 2: COT 6405: Analysis of Algorithmsgiri/teach/6405/f19/Lec/1-intro.pdf · CAP 5510 / CGS 5166 Text 3rd Edition • ISBN-13: 978-8120340077 • ISBN-10: 9788120340077 8/26/19!2

CAP 5510 / CGS 5166

Text3rd Edition

• ISBN-13: 978-8120340077

• ISBN-10: 9788120340077

8/26/19

!2

Page 3: COT 6405: Analysis of Algorithmsgiri/teach/6405/f19/Lec/1-intro.pdf · CAP 5510 / CGS 5166 Text 3rd Edition • ISBN-13: 978-8120340077 • ISBN-10: 9788120340077 8/26/19!2

Giri Narasimhan

Course Preliminaries! Course Webpage:

http: //www.cs.fiu.edu/~giri/teach/6405F19.html ! Lecture Slides; Reading Material; Announcements; HWs ! VISIT OFTEN!

! Class meets MW 2:00 – 3:15 PM, CASE/ECS 235 ! Office ECS 254B; Office Hours: By Appointment Only ! Phone: x-3748; Email: [email protected] ! Final: Monday, 12/11/2019, 12:00 – 2:00 PM, CASE 235 http: //www.cs.fiu.edu/~giri/teach/6405F19.html

6/26/18

!3

Page 4: COT 6405: Analysis of Algorithmsgiri/teach/6405/f19/Lec/1-intro.pdf · CAP 5510 / CGS 5166 Text 3rd Edition • ISBN-13: 978-8120340077 • ISBN-10: 9788120340077 8/26/19!2

CAP 5510 / CGS 5166

Momentos

! Slides and Audio online ! Need to register

! Go to https://fiu.momentos.life ! If you don’t already have an account

! Click on “Sign up” ! Follow instructions & use referral code: 5T6LSV

! If you have an account, “Add Course” with code 5T6LSV ! Verify account using link sent to email

8/26/19

!4

Page 5: COT 6405: Analysis of Algorithmsgiri/teach/6405/f19/Lec/1-intro.pdf · CAP 5510 / CGS 5166 Text 3rd Edition • ISBN-13: 978-8120340077 • ISBN-10: 9788120340077 8/26/19!2

CAP 5510 / CGS 5166

Why I am here?I am here because … ! It’s required

Hate being here because …! It’s required

8/26/19

!5

• What do I expect to learn in this class? • Who should know about Algorithms? • Is there a future in this field? • Would I ever need it if I want to be a software engineer or work

with databases?

Page 6: COT 6405: Analysis of Algorithmsgiri/teach/6405/f19/Lec/1-intro.pdf · CAP 5510 / CGS 5166 Text 3rd Edition • ISBN-13: 978-8120340077 • ISBN-10: 9788120340077 8/26/19!2

COT 5407 8/28/07

!6 Questions you should ask …

! What do I expect to learn in this class? ! Who should know about Algorithms? ! Is there a future in this field? ! Would I ever need it if I want to be a software

engineer or work with databases?

Page 7: COT 6405: Analysis of Algorithmsgiri/teach/6405/f19/Lec/1-intro.pdf · CAP 5510 / CGS 5166 Text 3rd Edition • ISBN-13: 978-8120340077 • ISBN-10: 9788120340077 8/26/19!2

Person of the Year …

Page 8: COT 6405: Analysis of Algorithmsgiri/teach/6405/f19/Lec/1-intro.pdf · CAP 5510 / CGS 5166 Text 3rd Edition • ISBN-13: 978-8120340077 • ISBN-10: 9788120340077 8/26/19!2

CAP 5510 / CGS 5166

Time’s Person of the Year

8/26/19

!8

2018 2017

Page 9: COT 6405: Analysis of Algorithmsgiri/teach/6405/f19/Lec/1-intro.pdf · CAP 5510 / CGS 5166 Text 3rd Edition • ISBN-13: 978-8120340077 • ISBN-10: 9788120340077 8/26/19!2

CAP 5510 / CGS 5166

The first hundred votes …

8/26/19

!9

48 12 9 12 23 12 22 12 12 1248 93 93 93 12 12 93 12 93 12

12 93 48 48 12 12 12 33 79 1212 12 93 12 12 9 12 23 12 1212 12 12 33 93 93 93 12 12 1212 9 12 23 93 48 48 12 12 4493 93 93 12 12 9 12 23 12 55

12 12 48 12 48 48 12 48 88 1212 12 93 12 12 9 12 23 12 1212 12 12 33 93 93 93 12 12 12

Who won a

majority?

Majority: More than 50% of the votes

Every number in the table corresponds to a vote for a person with that ID

Page 10: COT 6405: Analysis of Algorithmsgiri/teach/6405/f19/Lec/1-intro.pdf · CAP 5510 / CGS 5166 Text 3rd Edition • ISBN-13: 978-8120340077 • ISBN-10: 9788120340077 8/26/19!2

CAP 5510 / CGS 5166

Standard Approaches

! Keep a list of candidates and their counts ! Every vote needs to be compared against every

candidate in the worst case ! Sort the list and count

! Sorting is the bottleneck ! Can we avoid sorting?

8/26/19

!10

Page 11: COT 6405: Analysis of Algorithmsgiri/teach/6405/f19/Lec/1-intro.pdf · CAP 5510 / CGS 5166 Text 3rd Edition • ISBN-13: 978-8120340077 • ISBN-10: 9788120340077 8/26/19!2

CAP 5510 / CGS 5166 8/26/19

!11

48 93 93 93 12 12 93 12 93 12 93 12 12 9 12 23 12 93 93 93 12 9 12 23

12 93 48 48 12 12 12 33 79 12 12 33 93 93 93 12 12 93 48 48 93 93 93 12

12 12 93 12 12 9 12 23 12 12 12 23 93 48 48 12 12 12 93 12 93 48 48 12

12 12 12 33 93 93 93 12 12 12 93 12 12 9 12 23 12 12 12 33 12 9 12 23

12 9 12 23 93 48 48 12 12 44 48 48 12 48 88 12 12 9 12 23 48 48 12 48

93 93 93 12 12 9 12 23 12 55 12 9 12 23 12 12 93 93 93 12 12 9 12 23

12 12 48 12 48 48 12 48 88 12 93 93 93 12 12 12 93 12 48 12 93 93 93 12

12 12 93 12 12 9 12 23 12 12 12 9 12 23 12 55 12 12 93 12 12 33 79 12

12 12 12 33 93 93 93 12 12 12 12 12 12 33 93 93 93 12 12 12 12 23 12 12

48 48 12 12 12 33 79 12 12 33 93 93 93 12 12 93 48 12 33 79 93 12 12 12

93 12 12 9 12 23 12 12 12 23 93 48 48 12 12 12 93 12 23 12 48 12 12 44

12 33 93 93 93 12 12 12 93 12 12 9 12 23 12 12 12 93 12 12 12 23 12 55

12 23 93 48 48 12 12 44 48 48 12 48 88 12 12 9 12 48 12 12 12 48 88 12

93 12 12 9 12 23 12 55 12 9 12 23 12 12 93 93 93 12 23 12 12 23 12 12

48 12 48 48 12 48 88 12 93 93 93 12 12 12 93 12 48 12 48 88 12 23 12 12

93 12 12 9 12 23 12 12 12 9 12 23 12 55 12 12 93 12 23 12 93 12 12 12

93 12 12 9 12 23 12 12 12 23 93 48 48 12 12 12 93 12 23 12 48 12 12 44

12 33 93 93 93 12 12 12 93 12 12 9 12 23 12 12 12 93 12 12 12 23 12 55

12 23 93 48 48 12 12 44 48 48 12 48 88 12 12 9 12 48 12 12 12 48 88 12

93 12 12 9 12 23 12 55 12 9 12 23 12 12 93 93 93 12 23 12 12 23 12 12

48 12 48 48 12 48 88 12 93 93 93 12 12 12 93 12 48 12 48 88 12 23 12 12

48 48 12 12 12 33 79 12 12 33 93 93 93 12 12 93 48 12 33 79 93 12 12 12

93 12 12 9 12 23 12 12 12 23 93 48 48 12 12 12 93 12 23 12 48 12 12 44

12 33 93 93 93 12 12 12 93 12 12 9 12 23 12 12 12 93 12 12 12 23 12 55

12 23 93 48 48 12 12 44 48 48 12 48 88 12 12 9 12 48 12 12 12 48 88 12

93 12 12 9 12 23 12 55 12 9 12 23 12 12 93 93 93 12 23 12 12 23 12 12

48 12 48 48 12 48 88 12 93 93 93 12 12 12 93 12 48 12 48 88 93 93 12 12

93 12 12 9 12 23 12 12 12 9 12 23 12 55 12 12 93 12 23 12 9 12 23 12

12 23 93 48 48 12 12 44 48 48 12 48 88 12 12 9 12 48 12 12 12 48 88 12

93 12 12 9 12 23 12 55 12 9 12 23 12 12 93 93 93 12 23 12 12 23 12 12

48 12 48 48 12 48 88 12 93 93 93 12 12 12 93 12 48 12 48 88 12 23 12 12

93 12 12 9 12 23 12 12 12 9 12 23 12 55 12 12 93 12 23 12 93 12 12 12

Page 12: COT 6405: Analysis of Algorithmsgiri/teach/6405/f19/Lec/1-intro.pdf · CAP 5510 / CGS 5166 Text 3rd Edition • ISBN-13: 978-8120340077 • ISBN-10: 9788120340077 8/26/19!2

CAP 5510 / CGS 5166

Wacky Ideas, anyone?

! What if I pick two random votes and they turn out to be different? ! Discard and reduce the problem size

! What if I pick two random votes and they are the same? ! Well, this needs work and you will need to think

about it!8/26/19

!12

Page 13: COT 6405: Analysis of Algorithmsgiri/teach/6405/f19/Lec/1-intro.pdf · CAP 5510 / CGS 5166 Text 3rd Edition • ISBN-13: 978-8120340077 • ISBN-10: 9788120340077 8/26/19!2

CAP 5510 / CGS 5166 8/26/19

!13

48 12 9 12 23 12 22 12 12 1248 93 93 93 12 12 93 12 93 12

12 93 48 48 12 12 12 33 79 1212 12 93 12 12 9 12 23 12 1212 12 12 33 93 93 93 12 12 1212 9 12 23 93 48 48 12 12 4493 93 93 12 12 9 12 23 12 55

12 12 48 12 48 48 12 48 88 1212 12 93 12 12 9 12 23 12 1212 12 12 33 93 93 93 12 12 12

Page 14: COT 6405: Analysis of Algorithmsgiri/teach/6405/f19/Lec/1-intro.pdf · CAP 5510 / CGS 5166 Text 3rd Edition • ISBN-13: 978-8120340077 • ISBN-10: 9788120340077 8/26/19!2

Giri Narasimhan

Difference between Intro and Analysis of Algorithms?! More on how to analyze … more on complexity ! More on correctness … ! More algorithms … ! More data structures … bigger bag of tricks ! More on different algorithmic models …

! Randomized, online, amortized, adaptive, approximation, heuristic, quantum,

6/26/18

!14

Page 15: COT 6405: Analysis of Algorithmsgiri/teach/6405/f19/Lec/1-intro.pdf · CAP 5510 / CGS 5166 Text 3rd Edition • ISBN-13: 978-8120340077 • ISBN-10: 9788120340077 8/26/19!2

COT 5407 8/28/07

!15 Evaluation

! Exams (2) 45% ! Quizzes 10% ! HW Assignments 35% ! Class Participation 10%

Page 16: COT 6405: Analysis of Algorithmsgiri/teach/6405/f19/Lec/1-intro.pdf · CAP 5510 / CGS 5166 Text 3rd Edition • ISBN-13: 978-8120340077 • ISBN-10: 9788120340077 8/26/19!2

COT 5407

What you should already know …

! Array Lists ! Linked Lists ! Sorted Lists ! Stacks and Queues ! Basic Sorting

Algorithms

! Trees ! Binary Search Trees ! Heaps and Priority

Queues ! Graphs

! Adjacency Lists ! Adjacency Matrices

8/28/07

!16

Page 17: COT 6405: Analysis of Algorithmsgiri/teach/6405/f19/Lec/1-intro.pdf · CAP 5510 / CGS 5166 Text 3rd Edition • ISBN-13: 978-8120340077 • ISBN-10: 9788120340077 8/26/19!2

Giri Narasimhan

The Algorithmic Process

! Formulate the question ! Write down a basic idea, an approach ! Write down pseudocode ! Prove correctness ! Analyze pseudocode and think about upper and

lower bounds ! Iterate

6/26/18

!17

Page 18: COT 6405: Analysis of Algorithmsgiri/teach/6405/f19/Lec/1-intro.pdf · CAP 5510 / CGS 5166 Text 3rd Edition • ISBN-13: 978-8120340077 • ISBN-10: 9788120340077 8/26/19!2

COT 5407

History of Algorithms

! Euclid, 300 BC ! Bhaskara, 6th c ! Al Khwarizmi, 9th c ! Fibonacci, 13th c ! Gauss, 18-19th c

! Babbage, 19th c ! Turing, 20th c ! von Neumann, 20th c ! Knuth, Karp, Tarjan,

Rabin, …, 20-21st c

8/28/07

!18

Page 19: COT 6405: Analysis of Algorithmsgiri/teach/6405/f19/Lec/1-intro.pdf · CAP 5510 / CGS 5166 Text 3rd Edition • ISBN-13: 978-8120340077 • ISBN-10: 9788120340077 8/26/19!2

CAP 5510 / CGS 5166

Reading for next class

! Big-Oh notation ! Chapter 2, 3

! All sorting algorithms and their analysis ! Chapters 2, 6, 7, 8

8/26/19

!19