CMSC 203, Section 0401 Discrete Structures Fall 2004 Matt Gaston

Slides:



Advertisements
Similar presentations
22C:19 Discrete Math Algorithms and Complexity
Advertisements

College of Information Technology & Design
CSE115/ENGR160 Discrete Mathematics 03/01/12
Algorithms Chapter 3 Sec 3.1 &3.2 With Question/Answer Animations.
Complexity Theory  Complexity theory is a problem can be solved? Given: ◦ Limited resources: processor time and memory space.
Chapter 1 – Basic Concepts
CSE115/ENGR160 Discrete Mathematics 02/24/11 Ming-Hsuan Yang UC Merced 1.
CS420 lecture two Fundamentals
Analysis of Algorithms CPS212 Gordon College. Measuring the efficiency of algorithms There are 2 algorithms: algo1 and algo2 that produce the same results.
Algorithms Chapter 3 With Question/Answer Animations.
February 17, 2015Applied Discrete Mathematics Week 3: Algorithms 1 Double Summations Table 2 in 4 th Edition: Section th Edition: Section th.
1 Complexity Lecture Ref. Handout p
Chapter Complexity of Algorithms –Time Complexity –Understanding the complexity of Algorithms 1.
Discrete Structures Lecture 11: Algorithms Miss, Yanyan,Ji United International College Thanks to Professor Michael Hvidsten.
DISCRETE MATHEMATICS I CHAPTER 11 Dr. Adam Anthony Spring 2011 Some material adapted from lecture notes provided by Dr. Chungsim Han and Dr. Sam Lomonaco.
Algorithms Section 3.1. Problems and Algorithms In many domains there are key general problems that ask for output with specific properties when given.
22C:19 Discrete Structures Algorithms and Complexity Fall 2014 Sukumar Ghosh.
Fall 2002CMSC Discrete Structures1 Enough Mathematical Appetizers! Let us look at something more interesting: Algorithms.
MCA-2012Data Structure1 Algorithms Rizwan Rehman CCS, DU.
Chapter Algorithms 3.2 The Growth of Functions 3.3 Complexity of Algorithms 3.4 The Integers and Division 3.5 Primes and Greatest Common Divisors.
1 Section 2.1 Algorithms. 2 Algorithm A finite set of precise instructions for performing a computation or for solving a problem.
Chapter 5 Algorithms (2) Introduction to CS 1 st Semester, 2015 Sanghyun Park.
Big Oh Notation Greek letter Omicron (Ο) is used to denote the limit of asymptotic growth of an algorithm If algorithm processing time grows linearly with.
Counting Discrete Mathematics. Basic Counting Principles Counting problems are of the following kind: “How many different 8-letter passwords are there?”
The Fundamentals. Algorithms What is an algorithm? An algorithm is “a finite set of precise instructions for performing a computation or for solving.
ALGORITHMS.
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 2 The Fundamentals: Algorithms,
Chapter 3. Chapter Summary Algorithms Example Algorithms Growth of Functions Big-O and other Notation Complexity of Algorithms.
Ch03-Algorithms 1. Algorithms What is an algorithm? An algorithm is a finite set of precise instructions for performing a computation or for solving a.
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.
Chapter 3 With Question/Answer Animations 1. Chapter Summary Algorithm and Growth of Function (This slide) Algorithms - Sec 3.1 – Lecture 13 Example Algorithms.
Discrete Mathematics Chapter 2 The Fundamentals : Algorithms, the Integers, and Matrices. 大葉大學 資訊工程系 黃鈴玲.
Chapter 3 Sec 3.1 &3.2 With Question/Answer Animations 1.
The Growth of Functions: Selected Exercises
Algorithms Chapter 3.
CSE15 Discrete Mathematics 03/06/17
Growth of Functions & Algorithms
Applied Discrete Mathematics Week 2: Functions and Sequences
CSE15 Discrete Mathematics 03/13/17
COP 3503 FALL 2012 Shayan Javed Lecture 15
The Growth of Functions
Algorithms Chapter 3 Kenneth Rosen, Discrete Mathematics and its Applications, 7th edition, McGraw Hill Instructor: Longin Jan Latecki,
The Growth of Functions
Chapter 3, Section 3.1 Algorithms
Applied Discrete Mathematics Week 3: Algorithms
Enough Mathematical Appetizers!
Computation.
Lecture 3: Analysis of Algorithms
CS 2210 Discrete Structures Algorithms and Complexity
Algorithms Chapter 3 Kenneth Rosen, Discrete Mathematics and its Applications, 7th edition, McGraw Hill Instructor: Longin Jan Latecki,
Algorithms Chapter 3 With Question/Answer Animations
Analysis Algorithms.
Enough Mathematical Appetizers!
Algorithms Chapter 3 Kenneth Rosen, Discrete Mathematics and its Applications, 7th edition, McGraw Hill Instructor: Longin Jan Latecki,
CS 2210 Discrete Structures Algorithms and Complexity
Applied Discrete Mathematics Week 6: Computation
Algorithmic Complexity
Counting Discrete Mathematics.
Applied Discrete Mathematics Week 7: Computation
Enough Mathematical Appetizers!
Miniconference on the Mathematics of Computation
Combinations and Pascal’s triangle
Enough Mathematical Appetizers!
Algorithms Chapter 3 With Question/Answer Animations.
Algorithms Chapter 3 Kenneth Rosen, Discrete Mathematics and its Applications, 8th edition, McGraw Hill Modified and extended: Longin Jan Latecki,
Algorithms Chapter 3 With Question/Answer Animations
The Foundations: Logic and Proofs
Algorithms.
Discrete Mathematics CS 2610
CS 2210 Discrete Structures Algorithms and Complexity
Presentation transcript:

CMSC 203, Section 0401 Discrete Structures Fall 2004 Matt Gaston mgasto1@cs.umbc.edu http://www.csee.umbc.edu/~mgasto1/203

Algorithms Ch. 2.1-2.3

Definition Book definition: Better definition (?): Algorithm: a finite set of precise instructions for performing a computation or for solving a problem Better definition (?): Algorithm: An algorithm is a finite set of unambiguous, executable instructions that directs a terminating activity.

Algorithm Features Input Output Definiteness Correctness Finiteness Effectiveness Generality

Linear Search procedure linear search (x:integer, a1, a2, . . . , an: distinct integers) i := 1 while (i  n and x  ai) i := i + 1 if i  n then location := i else location := 0 10 13 17 1 4 18 3 5 11 9 8 16 2 7 6 14 15 19 20 18 12 How many steps? Worse case? On average?

Binary Search procedure binary search (x:integer, a1, a2, . . . , an: increasing integers) i := 1 j := n while (i  j) begin m :=  (i + j) / 2  if x  am then i := m + 1 else j := m end if x = ai then location := I else location := 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Growth of Functions Big-O Notation: C and k are called “witnesses Let f and g be functions from the set of integers to the set of integers or the set of real numbers to the set of real numbers. We say that f(x) is O(g(x)) if there are constants C and k such that | f(x) |  C | g(x) | whenever x > k.

Pictorial: Big-O Notation C g(x) f(x) g(x) k

Example 7x2 = O(x3)

Combinations of Functions f(x) = anxn + an-1xn-1 + . . . + a1x + a0 f(x) = O(xn) (f1 + f2)(x) = O(max( g1(x), g2(x) )) (f1f2)(x) = O(g1(x)g2(x))

Big-Omega Notation Let f and g be functions from the set of integers to the set of integers or the set of real numbers to the set of real numbers. We say that f(x) is (g(x)) if there are constants C and k such that | f(x) |  C | g(x) | whenever x > k.

Big-Theta Notation f(x) is of order g(x) Let f and g be functions from the set of integers to the set of integers or the set of real numbers to the set of real numbers. We say that f(x) is (g(x)) if f(x) is O(g(x)) and f(x) is (g(x)).

Bubble Sort procedure bubble sort (a1, a2, . . . , an) for i := 1 to n – 1 for j := 1 to n – i if aj > aj+1 then interchange aj and aj+1 {a1, a2, . . . , an is in increasing order }

Insertion Sort procedure insertion sort (a1, a2, . . . , an : real numbers with n  2) for j := 2 to n begin i := 1 while aj > ai i := i + 1 m := aj for k := 0 to j - i – 1 aj-k := aj-k-1 ai := m end {a1, a2, . . . , an are sorted }

Make Change!

Understanding Complexity n!, 2n, n2, n log(n), n, log(n), 1 Tractable/Intractable Solvable/Unsolvable – Halting Problem Class P, Class NP NP-Complete