CS 310: Analysis of Algorithms Spring 2016 1 Organizational Details Class Meeting: 1:00-3:45, Tuesday, UC249 Class Web Page: http://www.eagle.tamut.edu/faculty/igor/CS-EE-310.htm Instructor: Dr. Igor Aizenberg Office: Science and Technology Building, 104C Phone (903 334 6654) e-mail: igor.aizenberg@tamut.edu Office hours: Tuesday, Thursday 4:00p – 5:00p, Wednesday 1:00a – 3:00p 2 Text Book (Optional) T. H. Cormen, C.E. Leiserson, R. L. Rivest and C. Stein "Introduction to Algorithms", 3rd Edn.The MIT Press, McGraw-Hill Book Company, 2002 ISBN 978-0-262-03384-8 (hardcover) - ISBN 978-0-262-53305-8 (pbk) 3 Control Tests (open book, open notes): Test 1: February 23, 2016 Test 2: March 22, 2016 Test 3: May 3, 2016 Homework 4 Grading Grading Method Homework and preparation: Test 1: Test 2: Test 3: 25% 25% 25% 25% Grading Scale: 90%+ A 80%+ B 70%+ C 60%+ D less than 60% F 5 Algorithm What is an algorithm? 6 Algorithm in General An algorithm is a finite set of welldefined instructions for accomplishing some task which, given an initial state, will terminate in a defined end-state. To develop any algorithm, it is necessary to know, how the corresponding problem can be solved. 7 Algorithm in Computer Science An algorithm is any well-defined computational procedure that takes some value, or set of values, as input and produces some value, or set of values, as output. An algorithm is a sequence of computational steps (instructions) that transform the input into the output. 8 Algorithm in Computer Science An algorithm is a tool for solving a well-specified computational problem. The statement of the problem specifies in general terms the desired input/output relationship. The algorithm describes a specific computational procedure for achieving that relationship. 9 Solving Computational Problem Problem setting Design of an algorithm Analysis of the algorithm (proof of its correctness, analysis of its efficiency, comparison to other algorithms solving the same problem) Software implementation of the algorithm Solving the problem 10 So, what is this course about? 11 Solving Interesting Problems 1. 2. 3. 4. Design of algorithms (Methods and tools). Correctness of algorithms • Buggy algorithms are worthless! Efficiency of algorithms • Complexity, simplicity, running time, space needed, … Examples of efficient algorithm design • Fast algorithms in signal processing 12 Three Kinds of Problems: 1 Decision problems Given input, does it have a certain property? Is an integer prime? Is a graph planar? (Can be drawn on a plane without overlapping edges?) 13 Three Kinds of Problems: 2 Functional problems Given input, compute the unique solution. Compute the product of two matrices Sort an array Take the Fourier transform of a signal 14 Three Kinds of Problems: 3 Search problems Given input, compute any one of a set of solutions. Find the factors of an integer Find shortest path between two points in a graph Find the longest path between two points in a graph Find a record, which is marked by a certain key or contains a certain value of some data in a database 15 Properties of Algorithms: 1 Time efficiency As a function of its input size, how long does it take? Space efficiency As a function of its input size, how much additional space does it use? Most interested in asymptotic efficiency: worst-case & average-case 16 Properties of Algorithms: 2 Simplicity Informal notion Easier to code correctly Lower constant factors in efficiency (probably) Easier to explain Easier to prove the correctness More mathematically “elegant” 17 Basic Types of Algorithms Linear algorithm consists of a sequence of unconditional straightforward steps. Loop is a group of steps that are repeated until some condition will not be satisfied. Nested Loop is a loop containing another loop (loops). Branching algorithm consists of a number of subsequences that can be taken depending on some condition (conditions). 18 Modern computer technologies Hardware (including pipelining and superscalar architecture) Graphical User Interfaces (GUI) Object-oriented programming Networking (local-area and wide-area) ALGORITHMS 19 Algorithms Representation: Flowchart Data input Operations (Arithmetic) and Assignments Yes No Logical block (Branching) Data output 20