1 / 39

Syllabus

Syllabus. Go to www.cs.siena.edu/~ebreimer Click Analysis of Algorithms link bookmark course website Important stuff Schedule all due dates Quizzes details, solutions Homework details, solutions. Syllabus. Highlights Quiz every Friday HW due every Monday No exams except a final

brett-gould
Download Presentation

Syllabus

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Syllabus • Go to • www.cs.siena.edu/~ebreimer • Click Analysis of Algorithms link • bookmark course website • Important stuff • Schedule all due dates • Quizzes details, solutions • Homework details, solutions

  2. Syllabus Highlights • Quiz every Friday • HW due every Monday • No exams except a final • Combination of quizzes and HWs • No huge projects • Some HW will be collaborative

  3. Syllabus • Late HWs get a zero • Due at the beginning of class • Can drop 2 HWs • No quiz makeups • Miss a quiz, get a zero • Can drop 2 quizzes • Attendance 10% • 2 unexcused absences • -2% for each additional unexcused absence.

  4. Grading 40% Quizzes 30% HWs 20% Final 10% Attendance A  93 or higher A-  90 or higher B+  87 B  83 B-  80 C+  77 C  73 C-  70 Syllabus

  5. Chapter 1 – Intro • What is an algorithm? • 7 properties • Two Examples • Max of 3 • Closest Pair • Pseudo-code • Present • Future

  6. Algorithms? • Definition: step-by-step method for solving a problem • We will concentrate on algorithms that can be executed on modern computers • like the one you probably have • This field existed before computer existed • 900 AD in Persia

  7. 7 Properties • Input • Output • Precision • Determinism • Finiteness • Correctness • Generality

  8. Examples Problem: Given three integer values A, B, and C return the maximum value. Input: 3 integers Output: 1 integer

  9. Examples Problem: Given a list of N points, find the closest pair of points (2D) Input: N points, where a point is a pair of real values (x,y). Output: 2 points

  10. 3. Precision max(a,b,c) { compare a, b, and c and return the largest value; } Not precise!

  11. max(a,b,c) { if (a > b && a > c) return a; else if (b > c) return b; else return c; } Very precise 3. Precision

  12. 3. Precision • A precise algorithm is one that can be described by pseudo code or a high-level programming language like C++ or Java. • Pseudo code is like a high-level programming language where the syntax doesn’t have to be perfect.

  13. 4. Determinism • Not random • Given the same conditions, you expect the same outcome. • Computer are inherently deterministic. • When computers behave randomly it is usually a result of • human errors • environmental conditions • pseudo-random number generation

  14. 5. Finiteness • Given finite input, an algorithm should not run infinitely (i.e., forever). • An algorithm that runs forever is not really an algorithm because it will never solve the problem. • Recall that an algorithm is a step-by-step method for solving a problem. • What if the input is infinite?

  15. max(a,b,c) { if (a > b) return a; else if (b > c) return b; else return c; } What if a = 5 b = 4 c = 6 6. Correctness

  16. 6. Correctness • Algorithms that return incorrect answers aren’t really algorithms • Recall that an algorithm is a step-by-step method for solving a problem.

  17. 7. Generality max(a, b, c) { if (a > 10 && b < 10 && c < 10) return a; if (b > 10 && a < 10 && c < 10) return b; if (c > 10 && b < 10 && a < 10) return c; } Will never return an incorrect answer, but does not apply to a general set of input (like all integers or all real numbers).

  18. Closest Pair • Design an algorithm to find the closest pair of points

  19. Closest Pair • Designing algorithms is more of an art than a science.

  20. Closest Pair • Visually this problem is very simple to solve, but what if I gave you 1 million points?

  21. Closest Pair • What if I asked you to solve this problem for 1 million different cases?

  22. Closest Pair • What is the input? • What is the output? • What are the precise step-by-step instructions? • Will the algorithm terminate? • Will it produce correct answers all the time? • How much time will it take to solve? • How much memory is required to solve the problem?

  23. Closest Pair The input: • 2D point, a pair values (x, y) • Point p; • p.x; • p.y; • An array of n Points • Point P[n] • P[0], P[1], P[2], P[3], …, P[n-1]

  24. Closest Pair The output: • Two points P[a] and P[b] where the distance between P[a] and P[b] is minimum among all possible pairs of points. • Sometimes describing the output with precision gives you clues about how to solve the problem.

  25. Closest Pair • How do you compute the distance between to points? • How do you find a distance is minimum among all possible pairs of points?

  26. Closest Pair dist(a,b){ d = sqrt[ pow((a.x – b.x),2) + pow((a.y – b.y),2) ]; return d; }

  27. Closest Pair d = dist(P[0], P[1]); Compare all possible pairs of points, i.e.,compare P[0] with P[1], P[2], P[3], …, P[n-1]compare P[1] with P[2], P[3], P[4], …, P[n-1]compare P[2] with P[3], P[4], P[5], …, P[n-1]compare P[3] with P[4], P[5], P[6], …, P[n-1]…compare P[n-3] with P[n-2], P[n-1]compare P[n-2] with P[n-1]

  28. Closest Pair ClosestPair(P[ ], n) { min_dist = dist(P[0],P[1]); for (x = 1 to n-1) { d = dist(P[0], P[x]); if (d < min_dist) { min_dist = d; } } return min_dist; } This is not correct!

  29. Closest Pair ClosestPair(P[ ], n) { min_dist = dist(P[0],P[1]); for (y = 0 to n-1) { for (x = 1 to n-1) { d = dist(P[y], P[x]); if (d < min_dist) { min_dist = d; } }} return min_dist; }

  30. Closest Pair • Compare P[a] and P[b]

  31. Closest Pair • Compare P[a] and P[b]

  32. Closest Pair • Compare P[a] and P[b]

  33. Closest Pair ClosestPair(P[ ], n) { min_dist = dist(P[0],P[1]); for (y = 0 to n-1) { for (x = y+1 to n-1) { d = dist(P[y], P[x]); if (d < min_dist) { min_dist = d; } }} return min_dist; }

  34. Closest Pair • This matrix is n x n • n2 entries. • How many of these n2entries must we compute?

  35. Summations • n-1 + n-2 +n-3 +...+3 +2 +1

  36. The Present • Remember the 7 properties? • Many algorithms used in practice aren’t • General • Deterministic, or • Finite

  37. The Present • There are problems that are just too difficult to solve. • Compromises must be made. • Some algorithms only work on certain “types” of input. • Some algorithms require pseudo-random processing • Some algorithms will run forever on certain “types” or problems.

  38. The Present • Today, an algorithm doesn’t have to satisfy all the properties if the problem is very difficult and there is no other know way to get good answers. • Algorithms can be approximate, fuzzy, and even un-predicable. • Some Algorithm purist disagree with this. • But, I think a half-baked algorithm is better than no algorithm at all.

  39. The Future • Quantum computing. • Uses a quantum bit which can store an manipulate information in a massivle parallel way. • Theoretical only • Might be impossible to implement • DNA computing • DNA bases (A,C,G,T) will be used to represent data • Biological processes can manipulate large amounts of data in one step.

More Related