250 likes | 376 Vues
This course provides a comprehensive introduction to algorithms and data structures, covering essential concepts and evaluation techniques. Over 16 weeks of lectures and practical classes, students will learn about algorithm construction, various data structures, and their implementations in C language. Course grading comprises homework assignments and an examination. Key milestones include the completion of three homework tasks over the semester. The course aims to develop rational problem-solving skills through understanding classical algorithms and evaluating their efficiency.
E N D
Algorithms and Data Structures Lecture 1
Agenda: • Course Overview • Goals of the Course • Syllabus • Notation • Basics of Algorithms • Algorithms Evaluation
Course Overview: • Lectures, 32 hours, 16 weeks • Practical classes, 32 hours, 16 weeks • Grading consists of home works and examination • Examination (up to 80%) • Homework assignments (up to 20%) • 3 Homework assignments • Each homework consists of several small tasks
Milestones: • Home Work I Completes by March 1, 2002 • Home Work II Completes by April 1, 2002 • Home Work III Completes by May 1, 2002 • Examination Date is NA
Contacts: • Dmitri Brodski, Lecturer: dimetr@previo.ee • Mike Pikkov, Mentor for practical classes: pikkov@previo.ee • Course main WWW, lectures, homework assignments, announces: www.itcollege.ee/~dmitri • Practice materials, homework results: www.itcollege.ee/~mike
Organization: • Classes are not obligatory, you are free whether to visit or not • Home assignments could be obtained from WWW • Accomplished assignments should be sent by e-mail to a practice mentor: pikkov@previo.ee • Name, Group, IT College ID, Assignment ID
Environment: • Every standard “C” compiler is acceptable for training • MS VC 6.0 will be used during practical classes
Goals of the Course: • Give an overview of various classical algorithms • Give an overview of algorithm construction and evaluation • Give an overview of various data structures and their implementations in “C” language • Develop rational and creative approach to given tasks
Literature: • Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest Introduction to Algorithms • Jüri Kiho, Algoritmid ja Andmesruktuurid,Tartu 1994(1st edition), Tartu 1997 (2nd edition),Tartu Ülikool
Syllabus: • Basics of Algorithms • Algorithms Evaluation • Algorithms Construction • Data Structures • Sorting Algorithms • Graph Processing • Text Processing • Algorithms on Plane Geometry • Some Simple Mathematical Algorithms
Basics of Algorithms • Definition: Algorithm is a formally described computational procedure consisting of zero or more elementary steps. • Elementary step = evaluation, assignment, loop iteration and others. • Every algorithm works on some source data (INPUT) and produces some resulting data (OUTPUT); it is a function: OUTPUT = F(INPUT). • Every algorithm solves some computational problem what should be formally specified in terms of its INPUT and OUTPUT; e.g. sorting task INPUT: set of N numbers <a1, a2, … , an > OUTPUT: rearranged set <a’1, a’2, … , a’n > where a’1=< a’2=< … =< a’n.
Basics of Algorithms • Definition: Algorithms is correct if for any acceptable (for the problem) INPUT it always completes its execution and produces an OUTPUT that complies with the specification of the problem. • If algorithm is correct (regarding the given problem specification), we say that it solves the problem. • Sometimes incorrect algorithms may be useful if we need to solve a problem for some particular INPUT; usage of incorrect algorithms is a quite rare practice.
Algorithms Evaluation • Why do we analyze and evaluate various algorithms? • Definition: running time of an algorithm is a number of elementary operations performed by the algorithm for the given INPUT. • Each line of code has a value in terms of elementary operations, let’s denote it cj,where j – index of line. • Most common evaluation purpose is to determine a function describing how running time depends on the INPUT size; such a function is usually denoted as T(n) (time on n), n – characterizes size of INPUT
Algorithms Evaluation • T(n) = c1(n+1)+c2n+c3k+c5(n-k) • c3= c5, let’s use c3 instead of c5 • T(n) = c1(n+1)+c2n+c3k+c3(n-k) • T(n) = c1n+c2n+c3k+c3n-c3k+c1 • T(n) = c1n+c2n+c3n+c1 • T(n) = n(c1+c2+c3)+c1 • Let’s denote a = c1+c2+c3, b = c1 • T(n) = an+b, linear function
Algorithms Evaluation • Sometimes running time depends on kind of INPUT data; e.g. running time of sorting algorithm may depend on INPUT data, not only size of the INPUT; e.g. INPUT data may be already sorted or not sorted at all. • There are three measurable quantities available: best-case running time, worst-case running time and average-case running time. • Best-case running time – lowest value of running time that algorithm can spend handling INPUT of the size N. • Worst-case running time – highest value of running time that algorithm can spend handling INPUT of size N.
Algorithms Evaluation • Average-case running time – is mostly expected (or predicted) average time needed to handle an INPUT of size N; usually depends on probability distribution for particular type of INPUT data. • Best- and Worst- case running times may differ greatly. • Worst-case running time is most interesting measurable quantity, because ....
Algorithms Evaluation • If we know WCRT we may guaranty that the algorithm completes its execution in a certain time limit, for INPUT of given size. • In practice, worst-cases are highly probable, e.g. database query for non-existent element. • In practice, ACRT is very close to WCRT.
Algorithms Evaluation • BCRT(n) = c1+c2+c4+c5 • Let’s denote c = c1+c2+c4+c5 • BCRT(n) = c • c - some constant value for INPUT of any size • BCRT(n) in this case does not depend on ‘n’ • BCRT = C – constant function
Algorithms Evaluation • WCRT(n) = c1(n+1)+c2n • WCRT(n) = c1n+c2n+c1 • WCRT(n) = n(c1+c2)+c1 • Let’s denote a = c1+c2, b = c1 • WCRT(n) =an+b, linear function