140 likes | 320 Views
Design and Analysis of Algorithms. 4 th Semester Computer Engineering Ioana Sora ioana.sora@cs.upt.ro. Our goal:. design algorithms that are correct and efficient. The Need for Correctness.
E N D
Design and Analysis of Algorithms 4th Semester Computer Engineering Ioana Sora ioana.sora@cs.upt.ro
Our goal: designalgorithms that are correct andefficient
The Need for Correctness • Much too often, algorithms are designed in an ad-hoc manner and “validated” through testing on a few particular data sets …
The algorithm: A:array[1..n] of integer for i=1 to n-1 do if A[i]>A[i+1] swap(A[i], A[i+1]) The “tests”: Example of a “sorting algorithm” It works for 5, 1, 2, 7, 6 It works for 15, 2, 4, 17,16 But it does not work for 3, 2, 1, 5, 4 !
The Need for Correctness • Much too often, algorithms are designed in an ad-hoc manner and “validated” through testing on a few particular data sets … • The fact that an algorithm passed a number of tests on certain data sets DOES NOT guarantee that the algorithm is correct • The fact that an algorithm fails a test on ONE data set proves that it is NOT correct
A:array[1..n] of integer for l:=n downto 1 for i=1 to l-1 do if A[i]>A[i+1] swap(A[i], A[i+1]) How can we know for surethat the algorithm is correct ? (Other than simply believing the programming textbooks ;-)) The Bubblesort Algorithm
Analyzing Algorithms • We need methods and metrics to analyze algorithms for: • Correctness • Methods for proving correctness • Efficiency • Time complexity, Asymptotic analysis
Designing Algorithms • Clever people already designed a plethora of different sorting algorithms • How did they do it ? How did they get to the ideas? • How will we design solutions for new problems ?
Course Goals • Learn to design algorithms that are correct and efficient • How do we know that: • an algorithm is correct ? -> correctness proofs • an algorithm is efficient ? -> analysis of algorithms (time complexity) • How to design solutions for new problems ? • Learning general techniques for design • Studying a set of well-known algorithms, to serve as examples of success stories for applying general design techniques
Course Schedule • Review: Analysis • Proving Correctness of Algorithms. Induction • Design of Algorithms by Induction • Data structures: BST, Balanced trees, Augmented data structures • Graphs • Great algorithms in real life problems: • Data compression • Search engines
Course Webpage http://bigfoot.cs.upt.ro/~ioana/algo/
Lab Assignments • Comprise different types of exercises: • Questions - to be solved with pen on paper • Algorithm design problems • Examples: • A problem with a simple brute-force solution is given. Find a better solution. • An extension/change in one of the algorithms discussed in the lectures • This kind of assignments require to: • Describe the proposed algorithm • Analyze your algorithm (prove correctness and efficiency) • Implement the algorithm • Implementation projects • Simple implementations - implement something that was described in the course • Complex projects containing algorithm design
Examination and Grading • Final grade = 2/3 final written exam + 1/3 work during the semester • Written exam: • Questions and Algorithm design problems (such as these the lab description above) • Work during the semester: • Lab assignments • Lab quizzes • Course attendance • Optional bonus points: for exceptional activity and results during the semester/labs, you can gain extra-points to the grade of your final written exam