COMPSCI 330 Design and Analysis of Algorithms Rong

  • Slides: 21
Download presentation
COMPSCI 330 Design and Analysis of Algorithms Rong Ge

COMPSCI 330 Design and Analysis of Algorithms Rong Ge

Logistics • Lectures: Mondays and Wednesdays 3: 05 - 4: 20 PM • Recitations:

Logistics • Lectures: Mondays and Wednesdays 3: 05 - 4: 20 PM • Recitations: Check your own schedule • Recitations are required (5% of final grade)! • First week: Optional (Review of Induction/Sums) 1: 25 and 4: 40 in LSRC D 106, 3: 05 in Soc. Psych. 126 • Webpage: http: //www. cs. duke. edu/courses/spring 20/compsci 330/ • Office hours: Tuesday/Fridays 1 – 2 pm • TA office hours: See course webpage

Grades • Homework 35% (8, worst one will be dropped) • 2 Midterms 30%

Grades • Homework 35% (8, worst one will be dropped) • 2 Midterms 30% • Final Exam 30% • Homework should be typed and submitted to Gradescope. • Read (and follow) the guideline on collaboration. • Go to office hours!

STINF, Exam conflicts • Kate O’Hanlon is our teaching associate. • Email: kate. o.

STINF, Exam conflicts • Kate O’Hanlon is our teaching associate. • Email: kate. o. hanlon@duke. edu • We will not be able to offer make-up exams this semester. (Detailed policy on webpage soon) • For STINF please use a web form (will be posted on piazza later).

Contact us • Piazza: http: //piazza. com/duke/spring 2020/compsci 330 Please use for all general

Contact us • Piazza: http: //piazza. com/duke/spring 2020/compsci 330 Please use for all general discussions. • Piazza is required! All announcements will be on Piazza. • Grading questions: Please submit regrade requests through Grade. Scope. Homework requests will be handled by grad TAs and exam requests will be handled by myself. • Send me an email: rongge@cs. duke. edu

Lecture format • Slides first, then go to the board (tablet). • Best way

Lecture format • Slides first, then go to the board (tablet). • Best way of learning a proof is to write it down yourself. • I will try to record the lectures – hopefully the technology does not fail.

Algorithms • From wiki: In mathematics and computer science, an algorithm is a self-contained

Algorithms • From wiki: In mathematics and computer science, an algorithm is a self-contained sequence of actions to be performed.

Designing an Algorithm - Basics • Divide and conquer • Dynamic programming • Greedy

Designing an Algorithm - Basics • Divide and conquer • Dynamic programming • Greedy algorithms

Designing an Algorithm - Examples • Graph algorithms • DFS/BFS • Shortest paths •

Designing an Algorithm - Examples • Graph algorithms • DFS/BFS • Shortest paths • Minimum spanning tree • Data structrues • Hashing • Disjoint sets

Designing Algorithm – General Tools • Linear Programming • Formulation • Duality • Algorithms

Designing Algorithm – General Tools • Linear Programming • Formulation • Duality • Algorithms

Designing Algorithm - Intractability • What (we believe) cannot have efficient algorithms. • P

Designing Algorithm - Intractability • What (we believe) cannot have efficient algorithms. • P vs. NP • NP completeness • Reductions

Analysis - Proofs • Proof: Systematic way of convincing the reader that a mathematical

Analysis - Proofs • Proof: Systematic way of convincing the reader that a mathematical statement is necessarily correct. • Writing proofs is a major component of this course.

Proofs for algorithms? • Correctness: • 12343*9432583 = 116426471969 ? • (No: 116426371969) •

Proofs for algorithms? • Correctness: • 12343*9432583 = 116426471969 ? • (No: 116426371969) • More complicated: Why should I believe this is the shortest path to the airport?

Proofs for algorithms? • Running time: How long should the algorithm take. • Space:

Proofs for algorithms? • Running time: How long should the algorithm take. • Space: How much memory does the algorithm need.

Other aspects (not in this course) • Privacy/security

Other aspects (not in this course) • Privacy/security

Other aspects (not in this course) • Fault tolerance • Fairness

Other aspects (not in this course) • Fault tolerance • Fairness

Goal • Design new algorithms for applications you care. • Prove correctness/running time for

Goal • Design new algorithms for applications you care. • Prove correctness/running time for algorithms.

How to write a proof? • Will see many examples in class. • Very

How to write a proof? • Will see many examples in class. • Very similar to writing a program. Program • Unambiguous instructions for computers to solve a problem • Function/subroutine • System call/packages • Loop/Recursion • …… Proof • Unambiguous way of certifying a mathematical statement. • Lemma • Theorem • Induction • ……

Example • Prove that 1+2+3+… + n = n(n+1)/2 for all integers n. •

Example • Prove that 1+2+3+… + n = n(n+1)/2 for all integers n. • Idea: Base Case • Prove(n) • If n = 1 then say “ 1=1*2/2, easy” Induction Hypothesis • For k = 1 to n-1 • Show if [1+…+k = k(k+1)/2], then [1+…+k + (k+1) = (k+1)(k+2)/2] Induction Step

Example • Prove that 1+2+3+… + n = n(n+1)/2 for all integers n. •

Example • Prove that 1+2+3+… + n = n(n+1)/2 for all integers n. • Idea: • Prove(n) Base Case • If n = 1 then say “ 1=1*2/2, easy” • If n > 1 Induction Hypothesis • Prove(n-1) • Show if [1+…+(n-1) = n(n-1)/2], then [1+…+ n = n(n+1)/2] Induction Step

Rest of the lecture (on whiteboard) • Asymptotic notations • One of the earliest

Rest of the lecture (on whiteboard) • Asymptotic notations • One of the earliest algorithms: Euclid’s algorithm