0% found this document useful (0 votes)
20 views

DSAL-211-Lecture 4 - Important Discrete Mathematics

This document provides an overview of important concepts in discrete mathematics including set theory, recurrence relations, combinatorics, and graph theory. It discusses mathematical modeling and analyzing algorithm growth rates. Specific topics covered include basic set operations, solving recurrence relations using characteristic equations, permutations and combinations, graph definitions and applications, and examples of constant, linear, quadratic, and exponential growth functions.

Uploaded by

Kutemwa Mithi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

DSAL-211-Lecture 4 - Important Discrete Mathematics

This document provides an overview of important concepts in discrete mathematics including set theory, recurrence relations, combinatorics, and graph theory. It discusses mathematical modeling and analyzing algorithm growth rates. Specific topics covered include basic set operations, solving recurrence relations using characteristic equations, permutations and combinations, graph definitions and applications, and examples of constant, linear, quadratic, and exponential growth functions.

Uploaded by

Kutemwa Mithi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

DSAL-211 LECT 4: IMPORTANT

DISCRETE MATHEMATICS

By
W.G. Gondwe
Lecturer, Computer Networks
CS&IT Department
Malawi University of Science & Technology
Overview
• Relevant Mathematical Concepts
• Basic Set Theory (sets, functions, relations)
• Recurrence Relations
• Combinatorics (permutations, combinations, partitions, basic graph
theory)
• Mathematical Modelling & Growth Rates

DSAL-210 - Important Discrete Mathematics 2


Set Theory

DSAL-210 - Important Discrete Mathematics 3


Set Theory cont..

DSAL-210 - Important Discrete Mathematics 4


Set Theory cont…

DSAL-210 - Important Discrete Mathematics 5


Set Theory cont…
• Venn diagrams

DSAL-210 - Important Discrete Mathematics 6


Set Theory cont…

DSAL-210 - Important Discrete Mathematics 7


Set Theory cont…

DSAL-210 - Important Discrete Mathematics 8


Recurrence Relations
• Recursion: describing a process via itself
• More precisely, expressing a problem using a smaller version of itself
• Examples:
1. Exponential function
xn can be re-written as x * xn-1
With a base case or initial condition of x0 = 1
2. Fibonacci numbers:
Fn = Fn-1 + Fn-2
Base conditions: F0 =0 and F 1= 1

3. Factorial function:
n! = n * (n-1)!
or written as a recurrence relation:
Tn = 1 + Tn-1
Base conditions: T0 = 1
DSAL-210 - Important Discrete Mathematics 9
Recurrence relations cont…

DSAL-210 - Important Discrete Mathematics 10


Recurrence Relations cont..

DSAL-210 - Important Discrete Mathematics 11


Recurrence Relations
• Solving rr (using characteristic equation)
• Given a RR of order an = c1an-1 + c2an-2 + … cjan-k of order k, its
characteristic equation is given by:
xk – c1xk-1 - c2xk-2 - …. – ck = 0
Proposition:
If x is a solution to the characteristic equation the xn solves the
RR

DSAL-210 - Important Discrete Mathematics 12


Recurrence Relations
• Example
Given Fn = 4Fn-1 - 4Fn-2
Then:
k = 2, c1 = 4, c2 = -4
Hence, characteristic equation is given by:
x2 – 4x + 4 = 0
=> (x – 2)2 = 0
=> (x – 2)2 = 0
Therefore, x = 2 is a solution and consequently 2n solves Fn
(Recall if x is a solution to the characteristic equation the xn solves the
RR)
DSAL-210 - Important Discrete Mathematics 13
Combinatorics
• Study of counting, permutations & combinations of sets of
elements
• A critical set of discrete mathematics tools for algorithm analysis
• Has applications in cryptography, probability, coding and graph
theory
• We take a introductory look at combinations, permutations and
graph theory

DSAL-210 - Important Discrete Mathematics 14


Combinatorics cont..
• Permutations:
Q: In how many ways can you arrange 4 students on a queue?
Method:
Think of the queue as having 4 slots.
Them we have 4 choices for slot 1.
Once slot1 is used, we remain with 3 choices for slot 2
… and 2 choices for slot 2
… 1 choice for slot 1 4 3 2 1

In total, we have 4 x 3 x 2 x 1 = 4! = 24 different arrangements or


permutations
• Generally, there are n! (n-factorial) permutations for a list of n
different items
• Note: order matters in permutations: e.g. 3,1,2 and 3,2,1 are two
different permutations of the
DSAL-210 listDiscrete
- Important 1,2,3 Mathematics 15
Combinatorics cont..

Q: How many
permutations of the
word Mississippi?
DSAL-210 - Important Discrete Mathematics 16
Combinatorics cont..

DSAL-210 - Important Discrete Mathematics 17


Combinatorics cont..

DSAL-210 - Important Discrete Mathematics 18


Combinatorics cont..

DSAL-210 - Important Discrete Mathematics 19


Graph Theory

G = {V,E}
V = {6,4,5,1,2,3}
E=
{{6,4},{4,5},{4,3},{5,1},{5,2},{3,2},{1,2}}
DSAL-210 - Important Discrete Mathematics 20
Graph theory cont..
• Graph concepts:
• Degree of a vertex – number of edge incident on a vertex (loops are
counted twice) e.g. deg(7) = 3
• Graph can be undirected or directed
• Complete graph – every pair of vertices is
connected (edge between every pair)
• Multigraph – a graph with multiple edges
between one or more pairs of vertices

DSAL-210 - Important Discrete Mathematics 21


Graph theory cont..
• Graph applications
• Scheduling (timetabling using graph coloring)
• Routing algorithms
• Social graphs
• Linguistics/compiler design (finite state automata)
• Computer networks

DSAL-210 - Important Discrete Mathematics 22


Mathematical Modelling & Fn Growth
rates
• Recall: Complexity (time), worst-case assumption
• Analysis of algorithms – predicting how much resources an
algorithm will consume
• Analysis of algorithms – rate of increase in complexity as a
function of input
• i.e. Need to model a function of the algorithm in terms of input
size (n)

DSAL-210 - Important Discrete Mathematics 23


Mathematical Modelling cont..
• Example 1:
Algorithm to search for item p in a list of n items:
Analysis:
Assuming step i takes ci time to execute,
for counter := 1 to n 1 then the total execution time is given by:
if list[counter] = p then 2
nc1 + nc2 + nc5 + k , where k is a constant
return counter 3
else 4 (ignoring the trivial steps)
counter := counter + 1 5
end if 6 = n(c1 + c2 + c5) + k
= c0n + k (where c0 = c1 + c2 + c5)
end for 7
i.e. the growth function for the algorithm
is given by c0n + k (linear function of n)

DSAL-210 - Important Discrete Mathematics 24


Mathematical Modelling cont..
• Example 2:
Counting number of inversions:
Given a list a of size n, the number of inversions is a measure
of how unsorted it is.
It is measured by counting all a[i] > a[j] where i < j

Brute force (simple) algorithm:

inv_count := 0 1
for i := 1 to n 2
for j := i+1 to n 3
if a[i] < a[j] then 4
inv_count := inv_count + 1 5
end if 6
end for 7
end for 8
DSAL-210 - Important Discrete Mathematics 25
Mathematical modeling – Growth rates
• Types of growth rates (functions)
• Constant: f(n) = c
• Linear: f(n) = cn
• Log: f(n) = logb n
• Log-linear: f(n) = n log n Increasing
• Quadratic: f(n) = n2 + c complexity
• Cubic: f(n) = n3 + c
• Exponential: f(n) = cn
• Factorial: f(n) = n!

DSAL-210 - Important Discrete Mathematics 26


Math modelling – common algorith growth
rates

Graphical visualization of
algorithm complexities (growth
rates)

DSAL-210 - Important Discrete Mathematics 27

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy