The Fundamentals: Algorithms, the Integers & Matrices.

Slides:



Advertisements
Similar presentations
College of Information Technology & Design
Advertisements

College of Information Technology & Design
MATH 224 – Discrete Mathematics
BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS
Algorithms Chapter 3 Sec 3.1 &3.2 With Question/Answer Animations.
CompSci 102 Discrete Math for Computer Science
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
1 Module 2: Fundamental Concepts Problems Programs –Programming languages.
CSE115/ENGR160 Discrete Mathematics 02/24/11 Ming-Hsuan Yang UC Merced 1.
Lecture 2: Fundamental Concepts
1 Module 2: Fundamental Concepts Problems Programs –Programming languages.
CSE115/ENGR160 Discrete Mathematics 03/03/11 Ming-Hsuan Yang UC Merced 1.
Chapter 1 pp 1-14 Properties of Algorithms Pseudocode.
1 Chapter 2 Problem Solving Techniques INTRODUCTION 2.2 PROBLEM SOLVING 2.3 USING COMPUTERS IN PROBLEM SOLVING : THE SOFTWARE DEVELOPMENT METHOD.
Chapter 1 Introduction Definition of Algorithm An algorithm is a finite sequence of precise instructions for performing a computation or for solving.
February 17, 2015Applied Discrete Mathematics Week 3: Algorithms 1 Double Summations Table 2 in 4 th Edition: Section th Edition: Section th.
Chapter 2 The Fundamentals: Algorithms, the Integers, and Matrices
Chapter Complexity of Algorithms –Time Complexity –Understanding the complexity of Algorithms 1.
Chapter 3: The Fundamentals: Algorithms, the Integers, and Matrices
Discrete Mathematics Algorithms. Introduction  An algorithm is a finite set of instructions with the following characteristics:  Precision: steps are.
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.
Chapter 3 Sec 3.3 With Question/Answer Animations 1.
ดร.สุรศักดิ์ มังสิงห์ SPU, Computer Science Dept.
Introduction to Algorithms By Mr. Venkatadri. M. Two Phases of Programming A typical programming task can be divided into two phases: Problem solving.
Fall 2002CMSC Discrete Structures1 Enough Mathematical Appetizers! Let us look at something more interesting: Algorithms.
MCA-2012Data Structure1 Algorithms Rizwan Rehman CCS, DU.
1 Algorithms CS/APMA 202 Rosen section 2.1 Aaron Bloomfield.
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.
Section 3.1. Section Summary Properties of Algorithms Algorithms for Searching and Sorting Greedy Algorithms Halting Problem.
1 Algorithms CS 202 Epp section ??? Aaron Bloomfield.
1 Section 2.1 Algorithms. 2 Algorithm A finite set of precise instructions for performing a computation or for solving a problem.
CS 103 Discrete Structures Lecture 12
Counting Discrete Mathematics. Basic Counting Principles Counting problems are of the following kind: “How many different 8-letter passwords are there?”
UNIT-I INTRODUCTION ANALYSIS AND DESIGN OF ALGORITHMS CHAPTER 1:
ALGORITHMS.
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 2 The Fundamentals: Algorithms,
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Copyright © 2014 Curt Hill Algorithms From the Mathematical Perspective.
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.
Introductory Lecture. What is Discrete Mathematics? Discrete mathematics is the part of mathematics devoted to the study of discrete (as opposed to continuous)
Chapter 3 With Question/Answer Animations 1. Chapter Summary Algorithm and Growth of Function (This slide) Algorithms - Sec 3.1 – Lecture 13 Example Algorithms.
Section Recursion 2  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Section Recursion  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Discrete Mathematics Chapter 2 The Fundamentals : Algorithms, the Integers, and Matrices. 大葉大學 資訊工程系 黃鈴玲.
Chapter 3 Sec 3.1 &3.2 With Question/Answer Animations 1.
Algorithms (Section 3.1) The Growth of Functions (Section 3.2)
CSE15 Discrete Mathematics 03/06/17
Growth of Functions & Algorithms
Applied Discrete Mathematics Week 2: Functions and Sequences
Data Structures and Algorithms
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Enough Mathematical Appetizers!
Lecture 2: Introduction to Algorithms
Computation.
COMS W1004 Introduction to Computer Science and Programming in Java
Algorithms Chapter 3 With Question/Answer Animations
Analysis Algorithms.
Introduction to Algorithms
Rosen 5th ed., §2.1 ~31 slides, ~1 lecture
Applied Discrete Mathematics Week 6: Computation
Rosen 5th ed., §2.1 ~31 slides, ~1 lecture
Enough Mathematical Appetizers!
Discrete Mathematics and its Applications
Enough Mathematical Appetizers!
Algorithms.
Discrete Mathematics CS 2610
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Presentation transcript:

The Fundamentals: Algorithms, the Integers & Matrices

Algorithms 2 Some Applications: Use of number theory to make message secret Generate pseudorandom numbers Assign memory locations to computer files Internet security

Algorithms 3 Introduction Given a sequence of integers, find the largest one Given a set, list all of his subsets Given a set of integers, put them in increasing order Given a network, find the shortest path between two vertices

Algorithms 4 Methodology: Construct a model that translates the problem into a mathematical context Build a method that will solve the general problem using the model Ideally, we need a procedure that follows a sequence of steps that leads to the desired answer. Such a sequence is called an algorithm. story: the term algorithm is a corruption of the name Al-Khowarizmi (mathematician of the 9 th century)

Algorithms 5 Definition: An algorithm is a finite set of precise instructions for performing a computation or for solving a problem. Example: Describe an algorithm for finding the largest value in a finite sequence of integers Solution: We perform the following steps:

Algorithms 6 1. Set the temporary maximum equal to the first integer in the sequence 2. Compare the next integer in the sequence to the temporary maximum, and if it is larger that the temporary maximum, set the temporary maximum equal to this integer 3. Repeat the previous step if there are more integers in the sequence 4. Stop when there are no integers left in the sequence. The temporary maximum at this point is the largest integer in the sequence Pseudocode: intermediate step between an English language description of an algorithm and an implementation of this algorithm in a programming language

Algorithms 7 Finding the maximum element in a finite sequence Procedure max(a 1, a 2, …, a n : integer) { max := a 1 For i := 2 to n If max < a i then max := a i {max is the largest element} }

Algorithms 8 Properties of an algorithm: Input: an algorithm has input values from a specified set Output: from each set of input values an algorithm produces output values from a specified set. The output values are the solution to the problem Definiteness: the steps of an algorithm must be defined precisely Correctness: an algorithm should produce the correct output values for each set of input values Finiteness: an algorithm should produce the desired output after a finite (but perhaps large) number of steps for input in the set Effectiveness: it must be possible to perform each step of an algorithm exactly and in a finite amount of time Generality: the procedure should be applicable for all problems of the desired form not just for a particular set of input values.

Algorithms 9 Searching Algorithms Problem: “Locate an element x in a list of distinct elements a 1, a 2, …, a n, or determine that it is not in the list.” We should provide as a solution to this search problem the location of the term in the list that equals x.

Algorithms 10 The linear search Algorithm: The linear search algorithm Procedure linear search(x: integer, a 1, a 2, …, a n : distinct integers) i := 1 while (i  n and x  a i ) i := i + 1 if i  n then location := i else location := 0 {location is the subscript of the term that equals x, or is 0 if x is not found}

Algorithms 11 The binary search Constraint: can be used when the list has terms occurring in order of increasing size (words listed in lexicographic order) Methodology: Compare the element to be located to the middle term of the list

Algorithms 12 Example: Search 19 in the list split the list into 2 subsets with 8 terms each Compare 19 with the largest element of the first set 10< 19  search 19 in the second set Split the second subset into 2 smaller subsets Compare 19 with < 19  search 19 in the second set Split the second subset as: Compare 19 > 19 is false  search 19 in Split the subset as : Since 18 < 19  search restricted to the second list Finally 19 is located at the 14 th element of the original list

Algorithms 13 Procedure binary search (x: integer, a 1, a 2,…,a n : increasing integers) i := 1 {i is left endpoint of search interval} j := n {j is right endpoint of search interval} While i < j Begin m :=  (i + j)/2  If x > a m then i := m + 1 else j := m End If x := a i then location := i Else location := 0 {location is the subscript of the term equal to x, or 0 if x is not found}