Grading Exams 60 % Lab 20 % Participation 5% Quizes 15%

Slides:



Advertisements
Similar presentations
CSC401 – Analysis of Algorithms Lecture Notes 1 Introduction
Advertisements

Analysis of Algorithms1 Running Time Pseudo-Code Analysis of Algorithms Asymptotic Notation Asymptotic Analysis Mathematical facts COMP-2001 L4&5 Portions.
© 2004 Goodrich, Tamassia 1 Lecture 01 Algorithm Analysis Topics Basic concepts Theoretical Analysis Concept of big-oh Choose lower order algorithms Relatives.
Analysis of Algorithms Algorithm Input Output. Analysis of Algorithms2 Outline and Reading Running time (§1.1) Pseudo-code (§1.1) Counting primitive operations.
Complexity Analysis (Part I)
Analysis of Algorithms1 CS5302 Data Structures and Algorithms Lecturer: Lusheng Wang Office: Y6416 Phone:
Analysis of Algorithms (Chapter 4)
Analysis of Algorithms1 Estimate the running time Estimate the memory space required. Time and space depend on the input size.
Analysis of Algorithms
Cmpt-225 Algorithm Efficiency.
Fall 2006CSC311: Data Structures1 Chapter 4 Analysis Tools Objectives –Experiment analysis of algorithms and limitations –Theoretical Analysis of algorithms.
Algorithm Analysis CS 201 Fundamental Structures of Computer Science.
Introduction to Analysis of Algorithms Prof. Thomas Costello (reorganized by Prof. Karen Daniels)
Analysis of Algorithm.
Describing algorithms in pseudo code To describe algorithms we need a language which is: – less formal than programming languages (implementation details.
Analysis of Performance
1 i206: Lecture 6: Math Review, Begin Analysis of Algorithms Marti Hearst Spring 2012.
Pointers (Continuation) 1. Data Pointer A pointer is a programming language data type whose value refers directly to ("points to") another value stored.
CS2210 Data Structures and Algorithms Lecture 2:
Analysis of Algorithms Algorithm Input Output © 2014 Goodrich, Tamassia, Goldwasser1Analysis of Algorithms Presentation for use with the textbook Data.
Analysis of Algorithms Lecture 2
Analysis of Algorithms
Time Complexity Dr. Jicheng Fu Department of Computer Science University of Central Oklahoma.
Program Performance & Asymptotic Notations CSE, POSTECH.
Week 2 CS 361: Advanced Data Structures and Algorithms
Data Structures & AlgorithmsIT 0501 Algorithm Analysis I.
Analysis Tools Jyh-Shing Roger Jang ( 張智星 ) CSIE Dept, National Taiwan University.
Algorithm Efficiency CS 110: Data Structures and Algorithms First Semester,
Analysis of Algorithms
Analysis of Algorithms1 The Goal of the Course Design “good” data structures and algorithms Data structure is a systematic way of organizing and accessing.
Data Structures Lecture 8 Fang Yu Department of Management Information Systems National Chengchi University Fall 2010.
Analysis of Algorithms1 Running Time Pseudo-Code Analysis of Algorithms Asymptotic Notation Asymptotic Analysis Mathematical facts.
Complexity Analysis Chapter 1.
Analysis of Algorithms Algorithm Input Output Last Update: Aug 21, 2014 EECS2011: Analysis of Algorithms1.
Analysis of Algorithms
1 Analysis of Algorithms CS 105 Introduction to Data Structures and Algorithms.
1 Dr. J. Michael Moore Data Structures and Algorithms CSCE 221 Adapted from slides provided with the textbook, Nancy Amato, and Scott Schaefer.
Introduction to Data Structures and Algorithms CS 110: Data Structures and Algorithms First Semester,
Zeinab EidAlgorithm Analysis1 Chapter 4 Analysis Tools.
Analysis of Algorithms Algorithm Input Output © 2010 Goodrich, Tamassia1Analysis of Algorithms.
Analysis of algorithms. What are we going to learn? Need to say that some algorithms are “better” than others Criteria for evaluation Structure of programs.
Data Structures & Algorithms CHAPTER 1 Introduction Ms. Manal Al-Asmari.
Announcement We will have a 10 minutes Quiz on Feb. 4 at the end of the lecture. The quiz is about Big O notation. The weight of this quiz is 3% (please.
GC 211:Data Structures Week 2: Algorithm Analysis Tools Slides are borrowed from Mr. Mohammad Alqahtani.
1 COMP9024: Data Structures and Algorithms Week Two: Analysis of Algorithms Hui Wu Session 2, 2014
Analysis of Algorithms Algorithm Input Output © 2014 Goodrich, Tamassia, Goldwasser1Analysis of Algorithms Presentation for use with the textbook Data.
Data Structures I (CPCS-204) Week # 2: Algorithm Analysis tools Dr. Omar Batarfi Dr. Yahya Dahab Dr. Imtiaz Khan.
Analysis of Algorithms
COMP9024: Data Structures and Algorithms
COMP9024: Data Structures and Algorithms
Introduction to Algorithms
Data Structures and Algorithms
GC211Data Structure Lecture2 Sara Alhajjam.
Analysis of Algorithms
COMP9024: Data Structures and Algorithms
Lecture 3 of Computer Science II
Analysis of Algorithms
Analysis of Algorithms
Analysis of Algorithms
Algorithm design and Analysis
Analysis of Algorithms
Analysis of Algorithms
Chapter 2: Fundamentals of the Analysis of Algorithm Efficiency
Analysis of Algorithms
CS 201 Fundamental Structures of Computer Science
Analysis of Algorithms
Analysis of Algorithms
CS210- Lecture 2 Jun 2, 2005 Announcements Questions
Analysis of Algorithms
Presentation transcript:

Grading Exams 60 % Lab 20 % Participation 5% Quizes 15%

Pseudo-Code Pseudo-code is not a computer program, but is more structured than usual prose. Pseudo-code is –a mixture of natural language and high-level programming constructs –describe the main ideas behind a generic implementation of a data structure or algorithm. The programming language constructs we choose are those consistent with modern high- level languages such as C, C++, and Java.

Pseudo-Code Expressions: We use standard mathematical symbols to express numeric and Boolean expressions. –Left arrow sign (←) as the assignment operator in assignment statements (equivalent to the = operator in Java) –Equal sign (=) as the equality relation in Boolean expressions (equivalent to the "==" relation in Java). Method declarations: –declares a new method "name" and its parameters. Algorithm name(param1, par am2,…)

Pseudo-Code Decision structures: – if condition then true-actions [else false-actions]. –We use indentation to indicate what actions should be included in the true-actions and false-actions. While-loops: –while condition do actions. –We use indentation to indicate what actions should be included in the loop actions. Repeat-loops: –repeat actions until condition. –We use indentation to indicate what actions should be included in the loop actions

Pseudo-Code For-loops: –for variable-increment-definition do actions. –We use indentation to indicate what actions should be included among the loop actions. Array indexing: –A[i] represents the ith cell in the array A. –The cells of an n-celled array A are indexed from A[0] to A[n − 1] (consistent with Java). Method calls: –object.method(args) (object is optional if it is understood).

Pseudo-Code Method returns: –return value. –This operation returns the value specified to the method that called this one. Comments: –{ Comment goes here. }. –We enclose comments in braces. When we write pseudo-code, we must keep in mind that we are writing for a human reader, not a computer. –No low-level implementation details. –Not gloss over important steps. –Finding the right balance is an important skill that is refined through practice.

The Seven Functions We briefly discuss the seven most important functions used in the analysis of algorithms. The Constant Function f(n) = c, such as c = 5, c = 27, or c = it doesn't matter what the value of n is; f (n) will always be equal to the constant value c. Since we are most interested in integer functions, the most fundamental constant function is g(n) = 1. Note that any other constant function, f(n) = c, can be written as a constant c times g(n). That is,f(n) = cg(n) in this case. As simple as it is, the constant function is useful in algorithm analysis, because it characterizes the number of steps needed to do a basic operation on a computer, like –adding two numbers, –assigning a value to some variable, –or comparing two numbers.

The Seven Functions The Logarithm function f(n) = log b n, for some constant b > 1. The value b is known as the base of the logarithm. This function is defined as follows: x = log b n if and only if b x = n. By definition, log b 1 = 0. Computing the logarithm function exactly for any integer n involves the use of calculus, but we can use an approximation that is good enough for our purposes without calculus. In particular, we can easily compute the smallest integer greater than or equal to log a n, for this number is equal to the number of times we can divide n by a until we get a number less than or equal to 1. log 3 27 is 3, since 27/3/3/3 = 1. log 4 64 is 4, since 64/4/4/4/4 = 1 log 2 12 is 4, since 12/2/2/2/2 = 0.75 ≤ 1.

The Seven Functions Indeed, since computers store integers in binary, the most common base for the logarithm function in computer science is 2 –logn = log 2 n calculators have a button marked LOG, but this is typically for calculating the logarithm base-10, not base-two. (Logarithm Rules): Given real numbers a > 0, b > 1, c > 0 and d > 1, we have: 1.log b ac = log b a + log b c 2.log b a/c = log b a− log b c 3.log b a c = clog b a 4.log b a = (log d a)/log d b 5.b log d a = a log d b. Also, as a notational shorthand, we use logcn to denote the function (logn)c.

The Seven Functions The Linear function Another simple yet important function is the linear function, f(n)= n. That is, given an input value n, the linear function f assigns the value n itself. This function arises in algorithm analysis any time we have to do a single basic operation for each of n elements. For example, –comparing a number x to each element of an array of size n will require n comparisons. –The linear function also represents the best running time we can hope to achieve for any algorithm that processes a collection of n objects that are not already in the computer's memory, since reading in the n objects itself requires n operations.

The Seven Functions The N-Log-N function f(n) = nlogn, that is, the function that assigns to an input n the value of n times the logarithm base-two of n. This function grows a little faster than the linear function and a lot slower than the quadratic function. The Quadratic function f(n) = n 2. That is, given an input value n, the function f assigns the product of n with itself (in other words, "n squared"). The main reason why the quadratic function appears in the analysis of algorithms is that there are many algorithms that have nested loops, where the inner loop performs a linear number of operations and the outer loop is performed a linear number of times. Thus, in such cases, the algorithm performs n · n = n2 operations.

The Seven Functions The Cubic Function and Other Polynomials f(n) = n3, Polynomials A polynomial function is a function of the form, f(n) = a 0 + a 1 n + a 2 n 2 + a 3 n 3 + … + a d n d, where a 0,a 1,…,a d are constants, called the coefficients of the polynomial, and ad ≠ 0. Integer d, which indicates the highest power in the polynomial, is called the degree of the polynomial. Using a summation, we can rewrite the formula … + (n − 2) + (n − 1) + n = n(n + 1)/2 as:

Analysis of Algorithms The primary analysis tool we will use involves characterizing the running times of algorithms and data structure operations. Running time is a natural measure of "goodness," since time is a precious resource—computer solutions should run as fast as possible. In general, the running time of an algorithm or data structure method – increases with the input size –affected by the hardware environment and software environment. –we would like to focus on the relationship between the running time of an algorithm and the size of its input. We are interested in characterizing an algorithm's running time as a function of the input size. But what is the proper way of measuring it?