Introduction to Discrete Math' - PowerPoint PPT Presentation

1 / 25
About This Presentation
Title:

Introduction to Discrete Math'

Description:

The following table contains distance mileage distances between 6 cities. ... The selection of one alternative between two. if condition then. Statement. if ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 26
Provided by: csSung
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Discrete Math'


1
Introduction to Discrete Math.
  • 2003. 9.
  • ??????? ???????
  • ? ? ?

2
Discrete vs. Continuous
  • Continuous
  • Without interruption and without abrupt changes
  • ???
  • Analog watch
  • A set of real numbers (Uncountable)
  • Geometrically continuous representation
  • Discrete
  • Digital watch
  • Works in discrete quantities
  • A (finite) countable set of integers
  • Geometrically disconnected elements
  • Computer a finite discrete system

pm 0331
3
Discrete vs. Continuous
  • x x is a real number and 3.2 lt x lt9.5
  • x x is an integer and 3.2 lt x lt 9.5
  • Finite Countable Set
  • x x is a positive integer
  • Infinite Countable Set
  • x x is a positive real number

4
Discrete Mathematics
  • Mathematics A tool for problem solving
  • Mathematical modeling
  • The methodology for using mathematics for problem
    solving
  • Discrete Mathematics
  • a framework to understand the problems of
    designing digital computer systems and programs

Problem
Solution to the problem
Abstract Model
Transformed Model
5
Example-1
Jack has twelve apples, which cost him ten cents
apiece. How many apples must he sell at twenty
cents apiece before he begins to make a profit?
Problem
Income (sale price) (number sold) Expenses
(cost) (number bought)
Abstract Model
(sale price) x (cost) (number bought)
20 x 10 12
Transformed Model
Rules for simplifying the equation
x 120 / 20
Solution
x 6
6
Example (problem)-2
  • The following table contains distance mileage
    distances between 6 cities.
  • Find a road network of minimal total length that
    connects all the cities.

7
Example (Abstract Model)-2
  • Graph
  • Vertex a circle (city)
  • Edge a line (road between two cites)

8
Example (Rules for Transform)-2
  • Goal to reduce the graph to another graph of
    minimal total length that connects all the
    cities.
  • Algorithm (a set (sequence) of rules)
  • Select any vertex (city)
  • Connect it to the nearest adjacent vertex (city)
  • If there are unconnected vertices, locate the
    nearest one to one of the connected vertices, and
    connect these two vertices
  • Repeat the step 3 until all the vertices are
    connected

9
Example (Transform and Solve)-2
20
C
5
B
5
A
F
20
10
10
E
D
10
Example-3
C
3
B
2
  • Exercise 1.1 (modified)

A
3
G
1
3
D
F
3
E
C
3
B
2
A
3
G
1
D
3
F
3
E
There are several minimal networks (not unique).
11
Algorithm Description
  • Alternatives
  • Natural language (English, ??)
  • Ambiguous
  • Too long and too difficult to understand
  • A specific computer programming language
  • Too much details
  • There is no universal language for all
    programmers
  • Flowchart
  • Not good for defining structured algorithms
  • Too much freedom in describing control structures
  • Pseudo-code
  • A small set of structured language elements
  • Unambiguous and independent on a specific
    programming language
  • Very easy to translate the algorithm into an
    actual programming language

12
Basic Elements of Pseudo-code
  • Basic Building Block
  • Statements
  • Assignment statement
  • Action statement
  • Control statement

begin statements end.
13
Assignment Statements
  • A value to be assigned to a variable
  • variable_name ? expression
  • A ? A 1

Algorithm to compute the sum of two
numbers. begin Input First and Second Sum ?
First Second Output Sum end.
14
Action Statements
  • Describe an action
  • Input First and Second
  • Output Sum
  • Connect u to the nearest connected vertex

15
Control Statements
  • Describe the flow of control through the
    algorithm
  • Determine the execution order of the statements
    of the algorithm
  • Sequence (or compound) statements
  • Conditional Statements
  • Iterative Statements

16
Compound Statements
  • A list of statements to be executed in the order
    given.
  • Enclosed by begin and end

Statement 1
begin Statement1 Statement2 Statementn end.
Statement 2

Statement n
17
Conditional Statements
  • The selection of one alternative between two
  • if condition then
  • Statement

if condition then Statement1 else Statement2
Condition
true
false
Condition
false
true
Statement
Statement 2
Statement 1
18
Example-Conditional Statements
Algorithm to compute the absolute value of
n. begin Input n if n lt 0 then n ? - n abs
? n Output n end.
19
Example- if-else
Algorithm to find the larger value of two input
values. begin Input a and b if a gt b
then c ? a else c ? b Output c end.
20
Iterative Statements
  • for v ? initial_value to final_value do
  • Statement
  • for all elements of a set do
  • Statement
  • while expression do
  • Statement
  • repeat
  • Statement1
  • Statement2
  • Statementn
  • until condition

21
Example-for
Algorithm to sum the 1st ten positive integers.
begin sum ? 0 for i ? 1 to 10 do sum ? sum
i Output sum end.
22
Example-while
  • 0 or more execution of the statements

Algorithm to sum the 1st n positive odd
integers. begin sum ? 0 i ? 1 Input
n while i lt 2n do begin sum ? sum
i i ? i 2 end Output sum end.
false
i lt 2n
true
sum ? sum i
i ? i 2
Output sum
End
23
Example-repeat-until
  • 1 or more execution

Algorithm to sum the 1st n positive odd
integers. begin sum ? 0 i ? 1 Input
n repeat sum ? sum i i ? i 2 until i gt
2n if n 0 then sum ? 0 Output sum end.
sum ? sum i
i ? i 2
false
i gt 2n
true
24
Comments on Algorithms
  • Correctness
  • Efficiency

25
HW 1
  • Exercises 1.2
  • 1, 2, 3
  • Review Problems
  • 1, 2, 3, 4, 5, 8, 9
  • ???
  • Ex1.2? 2
  • R.P? 2, 4, 8 ?
Write a Comment
User Comments (0)
About PowerShow.com