Algorithms and their Applications CS2004 (2012-2013) Dr Stephen Swift 3.1 Mathematical Foundation.

Slides:



Advertisements
Similar presentations
Chapter 6 Matrix Algebra.
Advertisements

Sequences and Mathematical Induction
MATH 224 – Discrete Mathematics
Lecture 2 Introduction To Sets CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
COMPSCI 105 S Principles of Computer Science 12 Abstract Data Type.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Analysis of Algorithms1 Running Time Pseudo-Code Analysis of Algorithms Asymptotic Notation Asymptotic Analysis Mathematical facts COMP-2001 L4&5 Portions.
Complexity Analysis (Part I)
Object (Data and Algorithm) Analysis Cmput Lecture 5 Department of Computing Science University of Alberta ©Duane Szafron 1999 Some code in this.
© Love Ekenberg The Algorithm Concept, Big O Notation, and Program Verification Love Ekenberg.
Introduction to Analysis of Algorithms Prof. Thomas Costello (reorganized by Prof. Karen Daniels)
CSC 2300 Data Structures & Algorithms January 16, 2007 Chapter 1. Introduction.
2009 Mathematics Standards of Learning Training Institutes Algebra II Virginia Department of Education.
1 1.0 Students solve equations and inequalities involving absolute value. Algebra 2 Standards.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide P- 1.
Set theory Sets: Powerful tool in computer science to solve real world problems. A set is a collection of distinct objects called elements. Traditionally,
Chapter 10 Review: Matrix Algebra
Sequences Informally, a sequence is a set of elements written in a row. – This concept is represented in CS using one- dimensional arrays The goal of mathematics.
Systems of Linear Equation and Matrices
Copyright © Cengage Learning. All rights reserved.
Discrete Mathematics Algorithms. Introduction  An algorithm is a finite set of instructions with the following characteristics:  Precision: steps are.
Math 002 College Algebra Final Exam Review.
2.3 Functions A function is an assignment of each element of one set to a specific element of some other set. Synonymous terms: function, assignment, map.
1 Permutations and Combinations. 2 In this section, techniques will be introduced for counting the unordered selections of distinct objects and the ordered.
Analysis of Algorithms1 Running Time Pseudo-Code Analysis of Algorithms Asymptotic Notation Asymptotic Analysis Mathematical facts.
2.4 Sequences and Summations
Section 2.4. Section Summary Sequences. Examples: Geometric Progression, Arithmetic Progression Recurrence Relations Example: Fibonacci Sequence Summations.
Chapter P Prerequisites: Fundamental Concepts of Algebra P.4: Polynomials.
Chapter 19: Searching and Sorting Algorithms
Methods and Solving Equations
Discrete Mathematics Math Review. Math Review: Exponents, logarithms, polynomials, limits, floors and ceilings* * This background review is useful for.
Set, Combinatorics, Probability & Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Set,
Chapter 2 Mathematical preliminaries 2.1 Set, Relation and Functions 2.2 Proof Methods 2.3 Logarithms 2.4 Floor and Ceiling Functions 2.5 Factorial and.
Sets --- A set is a collection of objects. Sets are denoted by A, B, C, … --- The objects in the set are called the elements of the set. The elements are.
CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)
Divide & Conquer  Themes  Reasoning about code (correctness and cost)  recursion, induction, and recurrence relations  Divide and Conquer  Examples.
Grading Exams 60 % Lab 20 % Participation 5% Quizes 15%
CSNB143 – Discrete Structure Topic 6 – Counting Techniques.
Section Finding sums of arithmetic series -Using Sigma notation Taylor Morgan.
Module #12: Summations Rosen 5 th ed., §3.2 Based on our knowledge on sequence, we can move on to summations easily.
Sequences & Series MATH Precalculus S. Rook.
1 o-notation For a given function g(n), we denote by o(g(n)) the set of functions: o(g(n)) = {f(n): for any positive constant c > 0, there exists a constant.
Discrete Structure Sets. 2 Set Theory Set: Collection of objects (“elements”) a  A “a is an element of A” “a is a member of A” a  A “a is not an element.
Algorithms and their Applications CS2004 ( ) Professor Jasna Kuljis (adapted from Dr Steve Swift) 6.1 Classic Algorithms - Sorting.
CSC401 – Analysis of Algorithms Lecture Notes 2 Asymptotic Analysis Objectives: Mathematics foundation for algorithm analysis Amortization analysis techniques.
CS201: Data Structures and Discrete Mathematics I
Chapter 2: Basic Structures: Sets, Functions, Sequences, and Sums (1)
MATH 224 – Discrete Mathematics
College Algebra Sixth Edition James Stewart Lothar Redlin Saleem Watson.
Counting Discrete Mathematics. Basic Counting Principles Counting problems are of the following kind: “How many different 8-letter passwords are there?”
(CSC 102) Lecture 13 Discrete Structures. Previous Lectures Summary  Direct Proof  Indirect Proof  Proof by Contradiction  Proof by Contra positive.
Counting Principles Multiplication rule Permutations Combinations.
CompSci 102 Discrete Math for Computer Science February 7, 2012 Prof. Rodger Slides modified from Rosen.
CES 592 Theory of Software Systems B. Ravikumar (Ravi) Office: 124 Darwin Hall.
CS 285- Discrete Mathematics
A Introduction to Computing II Lecture 5: Complexity of Algorithms Fall Session 2000.
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 11 Basic Structure : Sets, Functions, Sequences, and Sums Sequences and Summations.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
Chapter 2 1. Chapter Summary Sets The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions and sequences.
Copyright © Cengage Learning. All rights reserved. Sequences and Series 9.1.
Sets, Permutations, and Combinations. Lecture 4-1: Sets Sets: Powerful tool in computer science to solve real world problems. A set is a collection of.
Applied Discrete Mathematics Week 2: Functions and Sequences
Sequences, Series, and Probability
MATH 224 – Discrete Mathematics
Chapter P Prerequisites. Chapter P Prerequisites.
Lecture 7 Functions.
Counting Discrete Mathematics.
Math/CSE 1019N: Discrete Mathematics for Computer Science Winter 2007
Arab Open University Faculty of Computer Studies Dr
Presentation transcript:

Algorithms and their Applications CS2004 ( ) Dr Stephen Swift 3.1 Mathematical Foundation

Mathematical FoundationSlide 2 Previously on CS2004… We looked at how to compare a number of algorithms Primitive Operations The core topic of counting Primitive Operations We discussed why experimental studies could not always be used as a comparison We looked at Pseudo-Code

Mathematical FoundationSlide 3 Mathematics For this module we are going to cover some mathematical topics Mathematics is a descriptive language It can be used to precisely describe how numerical items relate to each other It can be used to model the real world We will go over these slides rather quickly They should be used as a reference

Mathematical FoundationSlide 4 Why? Why do we need mathematics in this module and the other modules? Many of the techniques presented in this and other modules are based on a mathematical foundation Nearly all computer science research papers will use mathematical notation We can model the performance and efficiency of algorithms using mathematics

Mathematical FoundationSlide 5 What We are Going to Cover How to interpret simple equations and implement them in Java The basics: Variables Sets Equations Functions Subscripts Summation Products And a few other topics...

Mathematical FoundationSlide 6 What We are NOT Going to Cover Differentiation Integration Solving Equations Writing mathematical proofs Statistics But we will use simple summary statistics

Mathematical FoundationSlide 7 Variables – Part 1 A variable is a symbol used to represent a mathematical construct E.g. numbers, sets, lists, vectors, matrices, … Often lower case letters or Greek letters are used E.g. x, y, z, Ω, α, β, …

Mathematical FoundationSlide 8 Variables – Part 2 Variables in Mathematics are treated the same as variables within a programming language They can be thought of as a box containing a value that can be read from or written to

Mathematical FoundationSlide 9 Basics – Sets A set is a finite or infinite collection of items A set has no order A set only contains one copy of an item We write a  to say item a is a member of set A The empty set: ϕ |A| is the cardinality of A, i.e. How many items in A Some well known sets: R : Real numbers Z : Integers N : Natural numbers (integers ≥ 0) The alphabet

Mathematical FoundationSlide 10 Set Operators – Part 1 Creating: A = { : } A = { n 2 : n is an integer and 0 ≤ n ≤ 5} A = {0, 1, 4, 9, 16, 25} Union: A = B ∪ C, A = { a : a  B OR a  C } A contains all of B and C Intersection: A = B ∩ C, A = { a : a  B AND a  C } A contains only what B and C have in common) A

Mathematical FoundationSlide 11 Set Operators – Part 2 Subset: If A is a set then B  A ( B is a subset of A ) if every element of B is also in A, i.e. B is contained in A, e.g. N  Z, i.e. all natural numbers are integers Superset: In the example above A is a superset of B Set Subtraction: A = C\B, A = { a : a  C AND a  B } A is B with all the elements of C removed A B

Mathematical FoundationSlide 12 Equations – Part 1 An equation uses mathematical operators to relate one set of variables or numbers to another set of variables or numbers 2+2 = 4 (a very simple equation) y = mx +c (a straight line) ax 2 +bx+c=0 (a quadratic equation) (x-a) 2 +(y-b) 2 =r 2 (a circle of radius r with centre a,b )

Mathematical FoundationSlide 13 Equations – Part 2 Often we have to simplify an equation This often means adding up similar terms and ordering the powers E.g.: (n-1)(n-2)(n-3)=(n 2 -2n-n+2)(n-3)=(n 2 -3n+2)(n-3)=n 3 -3n 2 -3n 2 +9n+2n-6 =n 3 -6n 2 +11n-6 In a previous years exam 15% of the students did the following: n×n×n=3n!!!

Mathematical FoundationSlide 14 Functions – Part 1 A function is a relation that uniquely associates members of one set with members of another set Functions can take parameters, E.g. f(x,y)= 2x+y Functions can be many to one E.g. f(x) = 7 Functions can be one to one E.g. f(x) = 7x Functions can be many to one E.g. f(x) = x 2

Mathematical FoundationSlide 15 Functions – Part 2 There is a special function that we will be using in some of our work This is the exponential function f(x) = exp(x) = e x where e = 2.718…

Mathematical FoundationSlide 16 Subscripts – Part 1 A subscript is a natural number that indexes a list of variables. For example: Let X be the list [ x 1,...,x n ], then to access any element we use the notation x i, where 1≤ i ≤ n We use the notation |X| to refer to the number of elements in the list X, which is n in this case

Mathematical FoundationSlide 17 Subscripts – Part 2 For example: X = [5,2,-8,3.6,88, ] Then x 1 =5, x 2 = 2, x 3 = -8 etc… Note also that |X|=6 Note also that we use double subscripts for arrays (matrices)

Mathematical FoundationSlide 18 Summation – Part 1 Let X be the list [ x 1,...,x n ], then if we want sum all of the elements up, we would use the notation: Note that we are arbitrarily assigning the result to s. If we wanted to sum the squares:

Mathematical FoundationSlide 19 Summation – Part 2 Like with a for loop, the bottom value is the starting value, and the top value is the end value Note that i can be replaced by any other variable name, as long as you are consistent. By convention the variables i,j and k are often used for subscripts

Mathematical FoundationSlide 20 Products Let X be the list [ x 1,...,x n ], then if we want multiple together all of the elements, we would use the notation: Note that we are arbitrarily assigning the result to s. If we wanted to multiply the squares:

Mathematical FoundationSlide 21 Factorial The notation n! ( n factorial) is defined as multiply all of the integers between 1 and n together E.g. 6! = = 720 n ! also gives the number of possible arrangements of n items Note that 0! = 1

Mathematical FoundationSlide 22 Permutations The number of ways that r ordered items can be picked from n items is defined as:

Mathematical FoundationSlide 23 Combinations The number of ways that r unordered items can be picked from n items is defined as:

Mathematical FoundationSlide 24 Permutations and Combinations If the order is important then we use permutations otherwise we use combinations For example if the key code to a lock is 745 then 574 would not open it! Permutations, there are ways of choosing a 3 digit key code from the 10 digits If we like a fruit salad containing banana, pear and grapes, then the order doesn’t matter! Combinations, there are ways of choosing three fruits from ten fruits

Mathematical FoundationSlide 25 Floor and Ceiling Functions Floor  x  is the largest integer less than or equal to x  x   x  17.3  = 17 Ceiling  x  is the smallest integer greater than or equal to x  x   x  17.3  =18

Mathematical FoundationSlide 26 Logarithms – Part 1 Log b ( x ) = y means that x = b y Log b ( b )=1 b 1 = b for all b  0 Log b (1)=0 b 0 =1 for all b  0 Log b ( xy )= Log b ( x )+ Log b ( y ) Log b ( x/y )= Log b ( x )- Log b ( y ) Log b ( x y )= y Log b ( x ) Log b ( x )= Log a ( x )/ Log a ( b ) Log b ( x ) where x  0 is undefined

Mathematical FoundationSlide 27 Logarithms – Part 2 For example: Log 10 (1000) = 3 Log 2 (8) = 3 Note that: If y = exp(x) then Ln(y) = x natural logarithm This is known as the natural logarithm If y = a x b z then Ln(y) = Ln(a x )+Ln(b z ) = xLn(a)+zLn(b)

Mathematical FoundationSlide 28 Other Topics You May Need Probability Generating 1 in n chances Covered in level 1 Summing series Adding up n Covered in level 1 Summary statistics Mean, median, variance, etc... Covered in level 1

Mathematical FoundationSlide 29 Next Topic We will next look in more detail at Time Complexity and Asymptotic Notation The laboratory will be a Mathematical CAA Test