Professional Documents
Culture Documents
Discrete Mathematics
Discrete mathematics has become popular in recent decades because of its applications to
computer science. Concepts and notations from discrete mathematics are useful to study or
express objects or problems in computer algorithms and programming languages. In some
mathematics curricula, finite mathematics courses cover discrete mathematical concepts for
business, while discrete mathematics courses emphasize concepts for computer science
majors.
Natural language:
• If tomorrow is sunny, then I’ll go to downtown
• If tomorrow is sunny and the school is closed, or the school
is not closed but the bus is not in service, then I’ll go to
downtown or I’ll go to Richmond.
• If your account balance is lower than $1500 and there are
more than 10 transactions, or if your balance is greater than
$1500 and there are no more than 10 transactions, we will
charge a service fee of $10.
Math:
• If x>100 and y<50 or x<30 and not y<40, the system of
equations have a solution, subject to x and y are real
numbers.
Formal language:
• Language generated by grammars
• Grammars:
• Generate the words of a language
• Determine whether a word is in a language
• Words:
• Can be combined in various ways
• Grammars tell whether a combination of words is a valid
sentence
• Applications:
• Design of Programming Languages and Compilers
Example 1:
• Natural language: English
• Is “the hungry rabbits eats quickly” in English language?
• Derivation tree of the sentence:
sentence
Example 2:
• Typical problem in the construction of compilers.
• Determine whether the word cbab belongs to the
language generated by the grammar G = (V, T, S, P),
where:
• V = a, b, c, A, B, C, S
• T = a, b, c
• S is the starting symbol
• P are the productions:
S AB A Ca B Ba
B Cb Bb C cb
Cb
Example 5:
• The Traveling Salesman Problem
• Important in
• circuit design
• network routing
• many other CS problems
• Given:
• n cities c , c , . . . , c
1 2 n
4
1
Example 5 (continued):
• What can we do ?
• Do not waste time unless you are a genius to save the
world
• Less ambitious goals
• With 90% possible, find the best tour
• Find a tour that is no more 1.1 times the best