Department of Computer Science 1 COSC 2320 Section 14702 Room 104 AH 5:30 – 7:00 PM TTh Professor Olin Johnson Office 596 PGH 713-743-3343

Slides:



Advertisements
Similar presentations
Data Structures Using C++ 2E
Advertisements

Lecture 11: Algorithms and Time Complexity I Discrete Mathematical Structures: Theory and Applications.
Data Structures Using C++ 2E The Big-O Notation. Data Structures Using C++ 2E2 Algorithm Analysis: The Big-O Notation Analyze algorithm after design Example.
Razdan with contribution from others 1 Algorithm Analysis What is the Big ‘O Bout? Anshuman Razdan Div of Computing.
CS 3610/5610N data structures Lecture: complexity analysis Data Structures Using C++ 2E1.
Algorithmic Complexity Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Algorithmic Complexity 2 Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Cmpt-225 Algorithm Efficiency.
Algorithm Analysis CS 201 Fundamental Structures of Computer Science.
CS 206 Introduction to Computer Science II 01 / 28 / 2009 Instructor: Michael Eckmann.
Data Structures and Algorithms1 Basics -- 2 From: Data Structures and Their Algorithms, by Harry R. Lewis and Larry Denenberg (Harvard University: Harper.
Chapter 3: The Efficiency of Algorithms Invitation to Computer Science, C++ Version, Third Edition Additions by Shannon Steinfadt SP’05.
Analysis of Algorithms 7/2/2015CS202 - Fundamentals of Computer Science II1.
Elementary Data Structures and Algorithms
Analysis of Algorithms Spring 2015CS202 - Fundamentals of Computer Science II1.
Algorithm Analysis (Big O)
Spring2012 Lecture#10 CSE 246 Data Structures and Algorithms.
Analysis of Performance
Chapter 2.6 Comparison of Algorithms modified from Clifford A. Shaffer and George Bebis.
Week 2 CS 361: Advanced Data Structures and Algorithms
Lecture 2 Computational Complexity
Mathematics Review and Asymptotic Notation
CSC 201 Analysis and Design of Algorithms Lecture 04: CSC 201 Analysis and Design of Algorithms Lecture 04: Time complexity analysis in form of Big-Oh.
Algorithm Input Output An algorithm is a step-by-step procedure for solving a problem in a finite amount of time. Chapter 4. Algorithm Analysis (complexity)
g = PO D g = × 21 = × g = 12g 12g = 882 ÷12.
Coursenotes CS3114: Data Structures and Algorithms Clifford A. Shaffer Department of Computer Science Virginia Tech Copyright ©
A Lecture /24/2015 COSC3101A: Design and Analysis of Algorithms Tianying Ji Lecture 1.
Algorithm Analysis (Algorithm Complexity). Correctness is Not Enough It isn’t sufficient that our algorithms perform the required tasks. We want them.
Program Efficiency & Complexity Analysis. Algorithm Review An algorithm is a definite procedure for solving a problem in finite number of steps Algorithm.
Fundamentals of Algorithms MCS - 2 Lecture # 8. Growth of Functions.
Algorithm Analysis CS 400/600 – Data Structures. Algorithm Analysis2 Abstract Data Types Abstract Data Type (ADT): a definition for a data type solely.
Software Engineering Review CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and Computer Science.
Data Structures Using C++ 2E Chapter 1 Software Engineering Principles and C++ Classes.
Chapter 18: Searching and Sorting Algorithms. Objectives In this chapter, you will: Learn the various search algorithms Implement sequential and binary.
Chapter 5 Algorithms (2) Introduction to CS 1 st Semester, 2015 Sanghyun Park.
Java Methods Big-O Analysis of Algorithms Object-Oriented Programming
RUNNING TIME 10.4 – 10.5 (P. 551 – 555). RUNNING TIME analysis of algorithms involves analyzing their effectiveness analysis of algorithms involves analyzing.
CSC – 332 Data Structures Generics Analysis of Algorithms Dr. Curry Guinn.
Introduction to Analysis of Algorithms CS342 S2004.
General rules: Find big-O f(n) = k = O(1) f(n) = a k n k + a k-1 n k a 1 n 1 + a 0 = O(n k ) Other functions, try to find the dominant term according.
Data Structures Using C++ 2E
1 Algorithms  Algorithms are simply a list of steps required to solve some particular problem  They are designed as abstractions of processes carried.
Big-O. Algorithm Analysis Exact analysis: produce a function f(n) measuring how many basic steps are needed for a given inputs n On any input of size.
Asymptotic Notations By Er. Devdutt Baresary. Introduction In mathematics, computer science, and related fields, big O notation describes the limiting.
Algorithm Analysis (Big O)
Data Structures Using C++ 2E
Algorithm Analysis (Time complexity). Software development cycle -Four phases: 1.Analysis 2.Design Algorithm Design an algorithm to solve the problem.
Searching Topics Sequential Search Binary Search.
CISC220 Spring 2010 James Atlas Lecture 07: Big O Notation.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
1 Chapter 2 Algorithm Analysis All sections. 2 Complexity Analysis Measures efficiency (time and memory) of algorithms and programs –Can be used for the.
Algorithms Lecture #05 Uzair Ishtiaq. Asymptotic Notation.
Data Structures By Dr. Mehedi Masud ِAssociate Professor, Computer Science Dept. College of Computers and Information Systems Taif University 1.
Analysis of Algorithms Spring 2016CS202 - Fundamentals of Computer Science II1.
Chapter 3 Chapter Summary  Algorithms o Example Algorithms searching for an element in a list sorting a list so its elements are in some prescribed.
GC 211:Data Structures Week 2: Algorithm Analysis Tools Slides are borrowed from Mr. Mohammad Alqahtani.
CSE 3358 NOTE SET 2 Data Structures and Algorithms 1.
Data Structures & Algorithm CS-102 Lecture 12 Asymptotic Analysis Lecturer: Syeda Nazia Ashraf 1.
Asymptotic Notations Algorithms perform f(n) basic operations to accomplish task Identify that function Identify size of problem (n) Count number of operations.
Chapter 1 The Phases of Software Development
Data Structures Using The Big-O Notation 1.
Asymptotic Notations Algorithms perform f(n) basic operations to accomplish task Identify that function Identify size of problem (n) Count number of operations.
Programming and Data Structure
Advanced Analysis of Algorithms
Analysis of Algorithms
Programming and Data Structure
Asymptotic Notations Algorithms perform f(n) basic operations to accomplish task Identify that function Identify size of problem (n) Count number of operations.
Time Complexity Lecture 15 Mon, Feb 27, 2006.
G.PULLAIAH COLLEGE OF ENGINEERING AND TECHNOLOGY
Presentation transcript:

Department of Computer Science 1 COSC 2320 Section Room 104 AH 5:30 – 7:00 PM TTh Professor Olin Johnson Office 596 PGH Office Hours: 4:00 – 5:00 TTh 7:00 – 7:30 TTh COSC Data Structures Credit Hours: 3.0 (Lecture Contact Hours:3; Lab Contact Hours:0)TCCN Equivalent: [TCCN-COSC 2436] Prerequisite: COSC Introduction to various data structures (stacks, queues, lists, hash tables, trees, heaps, and graphs); sorting and searching; design, analysis, and comparison of algorithms.COSC 1320

Department of Computer Science 2 Big-O Notation Algorithm Analysis: The Big-O Notation Algorithm Analysis: The Big-O Notation Notation Analyze algorithm after design Example 50 packages delivered to 50 different houses 50 houses one mile apart, in the same area FIGURE 1-1 Gift shop and each dot representing a house

Department of Computer Science 3 Text Algorithm Analysis: The Big-O Notation (cont’d.) Example (cont’d.) Driver picks up all 50 packages Drives one mile to first house, delivers first package Drives another mile, delivers second package Drives another mile, delivers third package, and so on Distance driven to deliver packages … +1 = 50 miles Total distance traveled: = 100 miles FIGURE 1-2 Package delivering scheme

Department of Computer Science 4 FIGURE 1-2 Package delivering scheme Algorithm Analysis: The Big-O Notation (cont’d.) Example (cont’d.) Similar route to deliver another set of 50 packages Driver picks up first package, drives one mile to the first house, delivers package, returns to the shop Driver picks up second package, drives two miles, delivers second package, returns to the shop Total distance traveled 2 * (1+2+3+…+50) = 2550 miles

Department of Computer Science 5 Algorithm Analysis: The Big-O Notation (cont’d.) Example (cont’d.) n packages to deliver to n houses, each one mile apart First scheme: total distance traveled … +n = 2n miles Function of n Second scheme: total distance traveled 2 * (1+2+3+…+n) = 2*(n(n+1) / 2) = n 2 +n Function of n 2

Department of Computer Science 6 Algorithm Analysis: The Big-O Notation (cont’d.) Analyzing an algorithm Count number of operations performed Not affected by computer speed TABLE 1-1 Various values of n, 2n, n 2, and n 2 + n

Department of Computer Science 7 Algorithm Analysis: The Big-O Notation (cont’d.)  Example 1-1  Illustrates fixed number of executed operations

Department of Computer Science 8 Algorithm Analysis: The Big-O Notation (cont’d.)  Example 1-2 Illustrates dominant ops

Department of Computer Science 9 Algorithm Analysis: The Big-O Notation (cont’d.)  Search algorithm  n: represents list size  f(n): count function  Number of comparisons in search algorithm  c: units of computer time to execute one operation  cf(n): computer time to execute f(n) operations  Constant c depends computer speed (varies)  f(n): number of basic operations (constant)  Determine algorithm efficiency  Knowing how function f(n) grows as problem size grows

Department of Computer Science 10 Algorithm Analysis: The Big-O Notation (cont’d.) TABLE 1-2 Growth rates of various functions

Department of Computer Science Algorithm Analysis: The Big-O Notation (cont’d.) Figure 1-4 Growth rate of functions in Table 1-3 TABLE 1-3 Time for f(n) instructions on a computer that executes 1 billion instructions per second

Department of Computer Science 12 Algorithm Analysis: The Big-O Notation (cont’d.)  Notation useful in describing algorithm behavior  Shows how a function f(n) grows as n increases without bound  Asymptotic  Study of the function f as n becomes larger and larger without bound  Examples of functions  g(n)=n 2 (no linear term)  f(n)=n 2 + 4n + 20

Department of Computer Science 13 Algorithm Analysis: The Big-O Notation (cont’d.)  As n becomes larger and larger  Term 4n + 20 in f(n) becomes insignificant  Term n 2 becomes dominant term TABLE 1-4 Growth rate of n 2 and n 2 + 4n + 20n

Department of Computer Science 14 Algorithm Analysis: The Big-O Notation (cont’d.)  Algorithm analysis  If function complexity can be described by complexity of a quadratic function without the linear term  We say the function is of O(n 2 ) or Big-O of n 2  Let f and g be real-valued functions  Assume f and g nonnegative  For all real numbers n, f(n) >= 0 and g(n) >= 0  f(n) is Big-O of g(n): written f(n) = O(g(n))  If there exists positive constants c and n 0 such that f(n) = n 0

Department of Computer Science 15 Algorithm Analysis: The Big-O Notation (cont’d.) TABLE 1-5 Some Big-O functions that appear in algorithm analysis

Department of Computer Science 16 Text

Department of Computer Science 17 Text

Department of Computer Science 18 Text

Department of Computer Science 19 Text

Department of Computer Science 20 Text

Department of Computer Science 21 Text

Department of Computer Science 22 Text

Department of Computer Science 23 Text

Department of Computer Science 24 Text

Department of Computer Science 25 Text

Department of Computer Science 26 Text

Department of Computer Science 27 Text