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

Scs1210 Computer Science Discrete Mathematics Outline

The document outlines a proposed module template for a Computer Science course on Discrete Mathematics, detailing its overview, aims, learning outcomes, objectives, and assessment methods. Key topics include set theory, relations, and their applications in computer science, emphasizing mathematical reasoning and problem-solving techniques. Resources for the course include technology such as laptops and smartphones, and the assessment consists of assignments, tests, and a final examination.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Scs1210 Computer Science Discrete Mathematics Outline

The document outlines a proposed module template for a Computer Science course on Discrete Mathematics, detailing its overview, aims, learning outcomes, objectives, and assessment methods. Key topics include set theory, relations, and their applications in computer science, emphasizing mathematical reasoning and problem-solving techniques. Resources for the course include technology such as laptops and smartphones, and the assessment consists of assignments, tests, and a final examination.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 24

PROPOSED MODULE TEMPLATE

FACULTY Applied Science

DEPARTMENT Computer Science

PROGRAMME
BSC Honours in Computer Science
LEVEL Part 1

Module TITLE
Computer Science Discrete Mathematics
Module CODE SCS1210

FACILITATOR Mr. S Ngwenya

MODULE OVERVIEW Discrete Mathematics studies fundamental concepts and tools in


Mathematics with emphasis on their applications to Computer
Science. The course applies mathematical reasoning, proofs,
principle, and logic in problem-solving which relate to Computer
Science. Set theory is studied including relationships between finite
sets. The course gives the opportunity to learn mathematical
structures and techniques needed to solve problems in Computer
Science especially in computer science program development. It
forms the foundation for other courses in Computer Science where
students understand and create mathematical arguments in
problem-solving. The course puts emphasis on mathematical
concepts, proofs, and applications. The course includes set theory,
relations, functions, and relations which are fundamental in
computer programming and mathematical reasoning.

MODULE AIM By the end of the module, you should be able to apply fundamental
concepts and techniques in problem-solving and program
development in Computer Science and IT-related areas.
LEARNING OUTCOMES Programming skills, Present mathematical arguments in
programming. Problem solving.

OBJECTIVES  Apply sets concepts and properties in solving problems


involving sets.

1
 Prove that a relation is an equivalence relation by applying
the relation properties.
 Prove that a function is surjective, injective, and bijective.
 Determine the inverse and compositions of functions.
 Apply the laws and properties of probability to solve
problems involving discrete probability.
 Apply combinations and permutations in solving problems
and making use of product and sum rules.
 Find and ascertain the truth values of sentences using
logical connectives.
 Determine the truth value of a proposition and make a
representation on the truth table.
 Construct truth tables to determine the truth values of given
sentences
 Analyse and evaluate the characteristics of a Purely-
functional programming language.
 Develop algorithms that traverse a tree.

RESOURCES/TECHNOLOGY Laptops, Smartphones, Internet.

ASSESSMENT TYPE One assignment submitted.


Two tests.
Final examination.

W Module content subtopics


K
1 Topic 1: SETS

1.1. Introduction:
Sets are a collection of objects. The objects in the collection are its members or elements.
For example, we are all members of the set of all humans. Anything can be in a set. There
are sets of numbers, people, shapes, etc.
Notation: Set notation: Listing elements { }. Elements are listed in brackets and
separated by commas.
Set builder notation: P = {x: x is even, 2≤x<9}. This describes the set and elements are
listed using the given description. We list elements of sets like this: {0,1} The set
containing 0 and 1. {1, 2, 3, 4, 6, 7} The set containing natural numbers from 1 to 7. {1,
2, ...}. The set contains all the natural numbers. (Note: this set has infinitely many

2
members). {x: x is an even number} The set containing the even numbers {0, 2, 4, ...}
There are three main ways to specify a set:
(a) by listing all its members (list notation);
(b) by stating a property of its elements (predicate notation);
(c) by defining a set of rules which generates (defines) its members (recursive rules).
It is often intuitive to speak of “collecting” things together and “putting them into” a set,
but the idea is that the sets exist whether or not anyone has ever done any collection.
Moreover, notice that a set’s members do not need to be similar but must be drawn from
the same domain.

Key terms
Sets, objects, elements, collection.
Sets: Collection of objects.
Elements: Members of the set are referred to as objects.
Collection: Grouping of well-defined elements of a set using set notation

1.2. Sub-topic 1: Set theory


Set theory is a bunch of principles that describe sets. Why study set theory? Because sets
and their theory are important foundational tools in the development of computer Science
programs and computing philosophy. Hence the idea of collecting objects into one turns
out to be extremely useful. Set theory studies different types of sets, properties/principles
of sets, and their relationships.

Universal Set
When we define a set, we should specify where the elements in the set come from. This is a
specification of the Universal set and is denoted by the symbol . When all our sets are
subsets of real numbers, then our Universal set may be taken as the set of all real numbers.
Draw the Venn Diagrams to illustrate the concept of the Universal set.

The Boolean algebra of sets


Union
Let A and B be subsets of a universal set . The union of A and B, denoted A B, is the set of
all elements x in  such that x is in A or x is in B. Symbolically, A  B = {x Є U: x Є A or

Or Union A ∪ B = {x : x ∈ A ∨ x ∈ B}.
x Є B}.

Intersection
Let A and B be subsets of a universal set . The intersection of A and B, denoted A∩B, is
the set of all elements x in  such that x is in A and x is in B. Symbolically, A ∩B = {x Є :

Or Intersection A ∩ B = {x : x ∈ A ∧ x ∈ B}.
x Є A and x Є B}.

Difference
Let A and B be subsets of a universal set . The difference/Compliment of B minus A,
denoted B − A, is the set of all elements x in  such that x is in B and x is not A.
Symbolically, B − A = {x Є  : x Є B and x is not in A}. Or Difference A − B = {x : x
3
∈ A ∧ x ∉ B}.

Complement

A. Symbolically, Ac = {x Є : x ∉ A}.
The complement of A, denoted Ac, is the set of all elements x in  such that x is not in

Double Complement Law : For all sets A, (Ac)c = A.

Singleton Set
A set with one element. A = {7}.

This is an empty set: A = {} or ∅


Null Set

Subsets
If A and B are sets, the set A is called a subset of B, written A  B,
if every element of A is also an element of B. Symbolically, we have
A B x, if x Є A  x Є B. Define a proper subset.

Cartesian Product
Given two sets A and B, the Cartesian Product of A and B is defined
By A × B = {(a, b): a Є A  b Є B}.
Given that A={a, b, c)  B={1, 2, 3},
then AXB ={ (a,1), (a,2), (a,3),(b,1), (b,2), (b,3), (c,1), (c,2), (c,3)}

Power set
Given a set A, the power set of A is a set of all subsets of A and is denoted by p(A). For
example A={1,2}
then p(A) = {{},{1},{2},{1,2}}. For all set A and B if AB then p(A)p(B). For a set
X with n elements then p(X) has 2n elements where nЄZ, n0
Give examples
The power set P(A) of a set A is the set of all subsets of A. Suppose that A = {1; 2; 3; 4;
5}.
How many elements are there in p(A)?
List the elements of p(A)

Addition and Subtraction of sets


Given that X = {1, 2, 3} and Y = {3, 7, 9}, find
i) Y + X = {1,2,7,9} Take and list the elements that are in X and Y leaving out
repeating elements or elements that are in the intersection of the two sets. ii) X –
Y= {1,2}, Take and list the elements in X but not in Y, and note that elements in the
intersection are not considered.

Activity 1a

4
Show that:
A∪A = A
A∩A=A
2. Given that A= {a, b}
Write down the expression for the number of elements in the
power set.
Find the power set of A.
List the elements of AxA.
3. Given that X = {a, b, c, d} and Y = {a, d, e, f}, find
i) X – Y
ii) Y + X
iii) (X∩Y)
4. Prove that:
(A∪ B)c = (A∩B)c

P∪ (Q ∩ R) = (P ∪ Q) ∩ (P ∪ R)
(A∩ B)c=Ac∪Bc

1.3. Sub topic 2: Properties of sets/ The Boolean identities for sets

A∪B=B∪A A∪A=A
Commutativity Idempotent Laws

A∩B=B∩A A∩A=A

A ∪ (B ∪ C) = (A ∪ B) ∪ C A∪∅=A
Associativity Empty set

A ∩ (B ∩ C) = (A ∩ B) ∩C A∩∅=∅

A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C) A ∪ (A ∩ B) = A
Distributivity Absorption

A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C) A ∩ (A ∪ B) = A

Given that A and B are sets. Prove that:


(To show such algebraic identities between set expressions, one shows that
an element of the set on the left is an element of the set on the right, and vice versa).

A ∩ (B U C) = (A∩ B) U (A ∩ C)
From LHS : xЄA∩(BC)
xЄA and xЄ(BC) give reasons
xЄ(BC)
xЄA and xЄ B or xЄA and xЄC
xЄ(A∩ B)  xЄ (A∩C)
xЄ[(A∩ B)  (A∩C)], justify the steps
 A ∩ (B U C)  (A∩ B) U (A ∩ C)

5
same steps from RHS

De Morgan’s Laws
(A U B)c = Ac ∩ Bc (A ∩ B)c = Ac U Bc .

Sets in Computers
 Data: Unique storage, duplicate removal.
 Algorithms: Membership checks, graph work.
 Databases: Queries, unique records.
 Code: Data structures, character handling.

Reading sources/links
 Kenneth H. Rosen. Discrete Mathematics and Its Applications, Seventh Edition, McGraw-
Hill, 2012. ISBN 978-0072899054. QA39.3 R67 2012 (LC).

 WWL Chen: Discrete Mathematics

2 Topic 2: RELATIONS

2.1. Introduction:
The most direct way to express a relationship between elements of two sets is to use
ordered pairs made up of two related elements. For this reason, sets of ordered pairs are
called binary relations. In this topic we introduce the basic terminology used to describe
binary relations. Later we will use relations to solve problems involving communications
networks, project scheduling and identifying elements in sets with common properties
such as reflexive, symmetric, transitive and equivalence.

2.2. Key terms


Relation, reflexive, symmetric, transitive, equivalence.
 Let A and B be sets. A Relation R from A to B is a subset of A × B.
 A relation on a set A is a relation from A to A. Thus Relations from a set A to itself are

 A relation R on a set A is called reflexive if (a, a) ∈ R for every element a ∈ A.


of special interest.

 A relation R on a set A is called symmetric if (b, a) ∈ R whenever (a, b) ∈ R, for all a, b


∈ A.
 A relation R on a set A such that for all a, b ∈ A, if (a, b) ∈ R and (b, a) ∈ R, then a = b

 A relation R on a set A is called transitive if whenever (a, b) ∈ R and (b, c) ∈ R,


is called antisymmetric.

then (a, c) ∈ R, for all a, b, c ∈ A.


 An Equivalence Relation is reflexive, symmetric and transitive

 A relation R on a set A is called reflexive if (a, a) ∈ R for every element a ∈ A.


2.3. Sub topic 1: Properties of Relations

6
A relation R on a set A is called symmetric if (b, a) ∈ R whenever (a, b) ∈ R, for all a, b
∈ A.

 A relation R on a set A such that for all a, b ∈ A, if (a, b) ∈ R and (b, a) ∈ R, then a = b

A relation R on a set A is called transitive if whenever (a, b) ∈ R and (b, c) ∈ R,


is called antisymmetric.

then (a, c) ∈ R, for all a, b, c ∈ A.


 An Equivalence Relation is reflexive, symmetric and transitive

A relation R on Z is defined by writing (x,y) Є R if the Integer x – y is a multiple of 2.


Prove that R is an equivalence relation
2.4. Application on relational databases
Relations as Tables:
Tables from Relations:

In discrete mathematics, a relation is a set of ordered pairs. In relational databases,


these relations are realized as tables.

Domain and Cartesian Products:


The concept of a domain (the set of possible values for an attribute) and the
Cartesian product (the set of all possible ordered pairs) from discrete mathematics
directly influence how data types and possible data combinations are defined in
database schemas.

Key Applications:

Formalizing Database Structure:


Discrete mathematics provides the formal language to define the structure of a
relational database, ensuring clarity and precision in how data is organized.
This includes defining the relationships between different tables (e.g., one-to-
many, many-to-many) using concepts like foreign keys, which are rooted in the
mathematical definition of relations.

Relational Algebra:

Relational algebra, a set of operations used to manipulate relations, is a core


component of relational database theory. These operations (e.g., selection, projection,
join) are directly derived from the mathematical concepts of relations and set theory.

SQL (Structured Query Language), the standard language for interacting with relational
databases, is based on relational algebra.

Data Integrity and Constraints:

Concepts like functional dependencies and normalization, which are crucial for

7
maintaining data integrity, are based on the properties of relations studied in discrete
mathematics.
Constraints, such as primary key and foreign key constraints, enforce rules that
ensure the consistency and accuracy of data, and these rules are based on the
mathematical definition of relations.

Query Optimization:

Understanding the mathematical properties of relations allows database systems to


optimize query execution, improving performance.

Activity 2a

1. Given a Relation R={(1.1), (1,2), (2,2)}. Is R reflexive? The answer is YES


but why is it so?
2. Let A = {1,2,3}. State relation properties of
a) R={(1,2), (2,1), (1,1), (2,2)}
b) R={(1,1), (2,2), (3,3)}
c) R={(1,1), (2,2), (3,3), (1,2)}
3. A relation R is defined by writing (p,q) Є R if the integer p-q is a multiple of 3.
Investigate whether R is an equivalence relation or not.

Reading sources /links


 Kenneth H. Rosen. Discrete Mathematics and Its Applications, Seventh Edition, McGraw-
Hill, 2012. ISBN 978-0072899054. QA39.3 R67 2012 (LC).

3 Topic 3: FUNCTIONS

3.1 Introduction
A function is an expression, rule, or law that defines a relationship between one variable
(the independent variable) and another variable (the dependent variable). It is defined as
rule or law that defines a relationship between two or more sets. A function is like a
computing device that takes an input and gives an output. Functions enable programmers
to break down or decompose a problem into smaller chunks, each of which performs a
particular task. Once a function is created, the details of how it works can almost be
forgotten about. In this way the detail is abstracted, allowing the programmer to focus on
8
the bigger picture. Functions are used in the definition of such discrete structures as
sequences and strings. Functions are also used to represent how long it takes a computer
to solve problems of a given size. Many computer programs and subroutines are
designed to calculate values of functions. Recursive functions, which are functions
defined in terms of themselves, are used throughout computer science; In this topic we
will introduce the concept of a function, types of functions such as injective, surjective
and bijective; Also introduced are inverse of a function and composite functions; Proofs
and properties of functions.

3.2 Key terms


Function, injective, surjective, bijective
Function: A well-defined relationship between two or more sets.
Injective function: One-to-one function from set X to set Y such that each x in set X is
related to a different y in set Y.
Surjective function: A function f:X → Y is said to be surjective or onto if for every y in
set Y, there is an x in set X such that f(x) = y.
Bijective function: A bijective function is both injective and surjective (one to one and
onto) and must have an inverse.

3.2 Sub topic1: Function

Let A and B be sets. A function f from A to B assigns to each x ∈ A and element f(x) in
B. This is also referred to as a mapping or transformation between sets. WE write f: A →
B: x →f(x). In this case A is called the domain of the function and B is called the co-

f. F(B) = {y ∈ B: y = f(x) for some x ∈ A } is referred to as the range or image of the


domain of the function. The element f(x) is referred to as image of x under the function

function.

Linear Functions:

Definition:
A linear function has a degree of 1.
It's represented by the form: y = mx + b, where 'm' is the slope and 'b' is the y-
intercept.
Characteristics:
Forms a straight line when graphed.
Has a constant rate of change.
Example:
y = 2x + 3

Cubic Functions:

Definition:
A cubic function has a degree of 3.
It's represented by the form: y = ax³ + bx² + cx + d, where 'a' is not equal to 0.
Characteristics:

9
Forms an "S" shaped curve when graphed.
The rate of change is not constant.
can have up to 3 roots.
Example:
y = x³ - 6x² + 11x - 6

3.3 Sub topic 2: Injective function


Some functions never assign the same value to two different domain elements. These
functions are said to be injective. Therefore, an injective function is a one-to-one
function from set X to set Y such that each x in set X is related to a different y in set Y or
f :X → Y is 1-1 provided f(x1) = f(x2) implies x1 = x2 . If f:R → R is given by f(x) = 3x
+ 7, prove it is one-to-one. Why is f:R → R given by f(x) = x2 not 1-1?

3.4 Sub topic 3: Surjective function


A function f:X → Y is said to be surjective or onto if for every y in Y, there is an x in set
X such that f(x) = y. A function is onto when its image equals its range, i.e. f(X) = Y.
Show that f:R → R given by f(x) = 5x - 7 is onto/surjective.

3.5 Sub topic 4: Bijective function


A bijective function is both injective and surjective (one to one and onto)
The function must have an inverse f(x)-1. Investigate whether the function f(x) = 3x – 4
is bijective under real numbers. Also find its inverse.

3.6 Sub topic 5: Sum and products of functions


Given that f(x) = x – 2 and g(x) = x2 + 3x,
a) (f+g)(x)=f(x) + g(x): This is the sum of the functions.
b) g(x)*f(x): This is the product of the functions.
c) g(x) – 3f(x): Subtraction and scalar multiplication.
All what is followed to work on sum and product of functions is simply algebraic
manipulations and operations.

3.7 Sub topic 6: Inverse and composite functions


Let f be a one-to-one correspondence from the set A to the set B. The inverse function of
f is the function that assigns to an element b belonging to B the unique element a in A
such that f (a) = b. The inverse function of f is denoted by f−1. Hence, f−1(b) = a when f
(a) = b.

set C. The composition of the functions f and g, denoted for all a ∈ A by f ◦ g, is defined
Let g be a function from the set A to the set B and let f be a function from the set B to the

by (f ◦ g)(a) = f (g(a)). In other words, f ◦ g is the function that assigns to the element a of
A the element assigned by f to g(a). That is, to find (f ◦ g)(a) we first apply the function g
to a to obtain g(a) and then we apply the function f to the result g(a) to obtain (f ◦ g)(a) =
f (g(a)). Note that the composition f ◦ g cannot be defined unless the range of g is a subset
of the domain of f.

10
Activity 3a
1 Investigate whether the function f(x) = 3x – 4 is bijective under real
numbers.
2 Given that f(x) = 3x – 2 and g(x) = x2 + x, find
a) f(x) + g(x)

b) g(x) – 3f(x)
c) (fOg)(x)
e) f(x)-1

Reading sources/links

 Kenneth H. Rosen. Discrete Mathematics and Its Applications, Seventh Edition, McGraw-Hill, 2012.
ISBN 978-0072899054. QA39.3 R67 2012 (LC).

 WWL Chen: Discrete Mathematics

Topic 4: COMBINATORICS

4.1 Introduction

Combinatorics is the study of finite or countable discrete structures and includes counting the
structures of a given kind and size, deciding when certain criteria can be met, and constructing and
analysing objects meeting the criteria, finding "largest", "smallest", or "optimal" objects, and
studying combinatorial structures arising in an algebraic context, or applying algebraic techniques
to combinatorial problems.

4.2 Key terms Key terms


The Rule of Sum, The Rule of Product

 The Rule of Sum


If a first task can be performed in m, ways, while a second task can be performed in n ways and
the two tasks cannot be performed simultaneously, then performing either task can be
accomplished in one of the m † n ways
 The Rule of Product
If a procedure can be broken down into first and second stages, and if there are m possible
outcomes for the first stage and if, for each of these outcomes, there are n possible outcomes for
the second stage, then the total procedure can be carried out, in the designated order, in mn ways.

11
The two tasks are performed simultaneously.

Activity 4a
Example of the rule of sum
i. A college library has 40 textbooks on sociology and 50 textbooks dealing
with anthropology. In sum, a student at this college can select among
40†50=90 ways

Example of the rule of product


ii. The drama club of Central University is holding tryouts for a spring day.
With 6 men & 8 women auditioning for the leading male and female roles
the by-product, the director can cast his leading couple in 6×8=48 ways.

4.3 Sub topic1: Permutations


In permutations, the listing of the objects in a specified order is very important.
The keywords in a question requiring the use of permutations are distinct, different,
unique ways or methods. The permutations of the letters a,b,c are abc; acb; bac;
bca ;cab; cba & the permutations of size 2 are ab ac ad ba bc bd ca cb da db dc
NB In permutations order is important.

If there are n distinct objects and r, at time is an integer, with 1≤ r ≤n, then by the rule of
product, the numbers of size r for the n objects is
P(n,r)=n×(n-1)×(n-2)..........(n-r†1)
=n!÷(n-r)!
Where n! =1 ×2×3...............×n is called n factorial
when the number of objects n is equal to the size of arrangements r the permutation is
P(n ,n)= n!÷(n-n)!
=n!÷o!
=n!

Permutations with repeated symbols occur if there are n objects with n1


indistinguishable objects of a first type, n2 indistinguishable objects of a second type,....,
and nr indistinguishable objects of the rth type, n=n1†n2†.......†nk, then there are ; n!
÷(n1!n2!...nk)! linear arrangements of the given n objects.

Activity 4b
Example of Permutation
The number of permutations of the letters COMPUTER is
=8!
If only 5 of the letters are used, the number of permutations
P (8,5) = 8!÷(8-5)!

=6720

12
DATABASES
=9!÷3!2!
=30 240 possible arrangements

4.4 Sub topic2: Combinations

On many occasions we are not interested in the order of arrangement, but the number of
possible arrangements. Under such circumstances, we apply the combination principle.
The combination of r objects chosen from a set containing n of them is given by the
formulae: C(n,r)=P(n,r)÷r!

Activity 4c
Example of Combinations
i. A student taking a calculus exam is directed to answer any 7 of 10
essay questions. Find the number of ways he can answer the exam

C(10,7)= 10!÷7!(10-7)!
=10!÷7!3!
=120wayz

ii. If the student must answer 3 questions from the 5 and 4 from the last
5, for the first 3 is
C(5,3)=5!÷3!2! =10 ways

Other 4=5!÷4! =5ways


the student can complete the exam in 10×5=50

Reading sources/links

 Kenneth H. Rosen. Discrete Mathematics and Its Applications, Seventh Edition, McGraw-Hill, 2012.
ISBN 978-0072899054. QA39.3 R67 2012 (LC).

 WWL Chen: Discrete Mathematics

Topic 5: LOGICAL CONNECTIVES

5.1 Introduction
Logical connectives are symbols used to connect two or more logical statements. They
are also called logical operators because they are used to connect logical statements to
form compound statements from one or more logical statements.

13
5.2 Key terms
Proposition, Atomic
Proposition: sentence/statement that is true or false.
Atomic: a statement that cannot be logically broken into smaller statements.

5.3 Sub topic1: Words that express logical connectives in English


 "and" - conjunction.
 "and then" - conjunction with sequencing.
 "and then within" - conjunction with sequencing and time window requirement.
 "or" - disjunction.
 "either...or" - exclusive disjunction.
 "implies" – implication.
 "if...then" - implication.
 "if and only if" - equivalence.
 "only if" - implication.
 "just in case" – biconditional.
 "but" – conjunction.
 "however" - conjunction.
 "not both" - alternative denial.
 "neither...nor" - joint denial.

5.4 Sub topic 2: Assigning Truth Values to sentences/propositions

 Taking p and q to denote sentences: take T/1 – True and F/0 – False
 Propositional logic is composed of propositional symbols, logical connectives, and/or
parenthesis.
 Negation: P is True: p for NOT: p is T if p is F and F if p is T
 Disjunction: p q for OR is T if at least one of the sentences is T and is F otherwise
 Conjunction: p q for AND is T if the two sentences are both T and is F otherwise
 Conditional: pq for IF THEN: is T if P is F or q is T or both and is F otherwise
 Bi-conditional: pq for IF AND ONLY IF: T is both p, q are T or both F and are F
otherwise.

5.4 Sub-topic 3: Important concepts in propositional logic


 Tautology: A compound statement is a tautology if it is true regardless of the truth
values assigned to its component atomic statements. eg, either it is raining or it is not
raining.
 Contradiction: A compound statement is a Contradiction if it is false regardless of the
truth values assigned to its component atomic statements. eg, it is raining and it is not
raining.
 Contingency: A compound statement is contingent if it is true on some assignments of
truth values to its component atomic statements, and false on others. eg, Willard is either
a philosopher or a windbag, and he’s not a philosopher.

14
 Inverse: The inverse is formed by negating the hypothesis and negating the conclusion.
p → q: If you have a Sprite, then you have a root beer. ~ p → ~ q: If you do not have a
Sprite, then you do not have a root beer.
 Converse: The converse is formed by interchanging the hypothesis and the conclusion.
p → q: If it rained, then the ground got wet. q → p: If the ground got wet, then it rained.
 Contrapositive: The contrapositive is formed by negating both the hypothesis and the
conclusion, and then interchanging the resulting negations. p → q: If 15 is an odd
number, then 15 is a prime number. ~ q → ~ p: If 15 is not a prime number, then 15 is
not an odd number.

Activity 5a

Reading sources/links

 Kenneth H. Rosen. Discrete Mathematics and Its Applications, Seventh Edition, McGraw-Hill, 2012.
ISBN 978-0072899054. QA39.3 R67 2012 (LC).

 WWL Chen: Discrete Mathematics

Topic 6: GRAPH THEORY

6.1 Introduction
Graphs are discrete structures consisting of vertices and edges that connect these vertices.
There are different kinds of graphs, depending on whether edges have directions, whether
multiple edges can connect the same pair of vertices, and whether loops are allowed.
Problems in almost every conceivable discipline can be solved using graph models. Using

15
graph models, we can determine whether it is possible to walk down all the streets in a city
without going down a street twice, and we can find the number of colors needed to color
the regions of a map. Graphs can be used to determine whether a circuit can be
implemented on a planar circuit board. We can distinguish between two chemical
compounds with the same molecular formula but different structures using graphs. We can
determine whether two computers are connected by a communications link using graph
models of computer networks.

6.2 Key terms


Vertices, Edges/Arcs
Vertices: End points.
Edges/ Arcs: Line segments, connect to end points, connect vertices, have directions/no
directions.

6.2 Sub topic1: Types of Graphs


 Infinite graph: Infinite vertex set/edges set.
 Finite graph: Finite vertex set/edges set.
 Simple graph: Edges connect two different vertices and no two edges connect the same
pair of vertices.
 Multiple graphs/pseudographs: Multiple edges connecting the same vertices. A
communication link connects a computer to itself-feedback loop for diagnostic purposes.
 Directed graph/Digraph: Each edge is associated with an ordered pair of vertices denoted
by ( V , E ) .It consists of nonempty set of vertices V and a set of directed edges/arcs E .
 Simple directed graph/Digraph: No loops, no multiple directed edges.
 Undirected graph: Edges with no directions.
 Mixed graph: Directed and undirected edges.
 [Complete graphs, trees, cycles, wheels, cubes, complete bipartite]

6.3 Sub topic 2: Adjacent Vertices And Vertex Degree


Suppose u , v are adjacent/neighbours if u and v are end points of an edge e in an
undirected graph. Notation: N ( vertex ) . e is said to be incident with u , v . e connects u , v .
Vertex degree/degree of vertex: number of edges incident with it including loops. NB:
loops contribute twice. Notation: Deg ( Vertex )

For a set V with n elements, how many possible edges are there? Number of edges
(vallency)in a directed graph ¿ n ( n−1 ) .The number of edges¿ n(n−1)/2
(undirected graph). Number of graphs = 2 n(n−1)/2

Activity 6a
How many edges are there in a graph with 10 vertices, each of degree 6?
Applying handshaking theorem.
Let G=(V , E)be an undirected graph with m edges.

16
2 m=∑ deg ⁡(v), N (V )=10 , deg ⁡(1)=deg ⁡(2)=… … ..=6.
∑ deg ⁡( v ) = 60
2 m=60thus sum of the degrees of vertices is an even number, meaning graph
G has an odd degree.
m=30.

Application of graphic theory in computer networks and information systems.


1. Network Topology and Design:

Modeling Network Structures:


Computer networks, whether local area networks (LANs) or wide area networks (WANs), can be
represented as graphs. Devices (computers, routers, servers) are nodes (vertices), and connections
between them are edges.

Graph theory helps in understanding and designing network topologies (e.g., star, mesh, tree) for
optimal performance and reliability.

Optimization:

Graph algorithms help in designing efficient network layouts, minimizing cable lengths, and reducing
costs.

2. Routing Algorithms:

Finding Optimal Paths:


Routing protocols use graph algorithms (like Dijkstra's algorithm) to find the shortest or most
efficient paths for data packets to travel through a network.

This ensures fast and reliable data transmission.

Network Congestion Control:

Graph theory aids in analyzing network traffic patterns and developing strategies to prevent
congestion and bottlenecks.

3. Network Security:

Network Vulnerability Analysis:


Graph theory can be used to identify critical nodes and potential points of failure in a network.

It helps in analyzing network security vulnerabilities and developing strategies to protect against
attacks.

17
Intrusion Detection:

Graph-based techniques can be used to detect anomalies and suspicious patterns in network traffic,
indicating potential security breaches.

4. Social Network Analysis:

Information Flow:
Social networks are inherently graphs, with users as nodes and connections as edges.

Graph theory helps analyze information flow, identify influential users, and understand network
dynamics.

Data Mining:

Graph-based data mining techniques are used to discover patterns and relationships in social
network data.

5. Database Systems:

Graph Databases:
Graph databases use graph structures to store and query data, which is particularly useful for
representing and querying relationships between data entities.

These databases are well-suited for applications involving complex relationships, such as social
networks and recommendation systems.

Reading sources/links
 Kenneth H. Rosen. Discrete Mathematics and Its Applications, Seventh Edition, McGraw-Hill, 2012.
ISBN 978-0072899054. QA39.3 R67 2012 (LC).

Topic 7: REASONING ABOUT PROGRAMS THEORY

7.1 Introduction
A tree traversal, also known as tree searches, are algorithms executed on graphs containing
only tree edges, that visit each node exactly once. Algorithms in this category differ only in the
order in which each node is visited. Two classic methods to traverse a tree are breadth-first
search (bfs), where nodes in the same level or distance away from the root are visited before
proceeding to the next level; and depth-first-search, where all the nodes in a branch, or one set
path from root to leaf, are visited before passing on to the next branch.

7.2 Key terms


Tree, Parent, Leaves, Internal node, Siblings, Binary tree Depth of node, Depth of a

18
tree, Height of a node.
Tree: A tree is a collection of nodes.
Parent: The root of each subtree is said to be a child of r and r is said to be the parent of
each subtree root.
Leaves: Nodes with no children /external nodes.
Internal Nodes: nodes with children.
Siblings: Nodes with the same parent.
Binary tree: A tree in which no node can have more than two children. Each node has an
element, a reference to a left child, and a reference to a right child
Depth of node: The length of the unique path from the root to a node.
Depth of tree: The depth of a tree is equal to the depth of its deepest leaf.
Height of node: The length of the longest path from a node to a leaf.

7.1 Sub topic1: Traversal algorithms


• A pre-order traversal prints the contents of a sorted tree in pre-order. The contents of
the root node are printed first, followed by the left subtree, and finally the right subtree.
• In an in-order traversal the contents of the sorted tree are printed in order. It starts with
the lowest value first and then increases its value as it traverses the tree. If the tree uses
strings or characters and would be increasing numerically from 0 if the tree contains
numerical values.
• A post-order traversal prints the contents of a sorted tree in post-order. The contents of
the left subtree are printed first followed by the right subtree and finally the root node.

Activity 7a

19
Solution

Reading sources/links

 Kenneth H. Rosen. Discrete Mathematics and Its Applications, Seventh Edition, McGraw-Hill, 2012.
ISBN 978-0072899054. QA39.3 R67 2012 (LC).

Topic 8: PREDICATE LOGIC AND QUANTIFIERS

8.1 Introduction
A quantifier is used to quantify the variable of predicates. It contains a formula, which is a type
of statement whose truth value may depend on the values of some variables. When we assign a
fixed value to a predicate, then it becomes a proposition. In another way, we can say that if we
quantify the predicate, then the predicate will become a proposition. So quantify is a type of
word that refers to quantifies like "all" or "some".

20
8.2 Key terms
Predicate, Quantifiers
Predicate: A predicate is a property that describes a variable.
Quantifiers: These are phrases such as “For all”, “For very”, “For each”, “For some”,
that tell some sense how many objects have a certain property.

8.3 Sub topic 1: Universal Quantifier


“” reads “for all”, “for every”, “for each”, “for any”. Thus the sentence for Every x,
x>0, can be symbolised as (x) (x>0).
A quantifier and its name variable are placed in prentices and the phrase (x>0)”
describes a property of a variable x that of being positive.

General format: (x) (P(x))


P(x) depends on domain of objects in which we are interpreting the expression P(x) be a
predicate, then the statement (∀x)P(x) is true iff P(x) is true for every variable x.
Let P(x) be a statement x>5 → x>3. P(x) is universally true for every real number x.
Therefore the expression (∀x)P(x) is true,
(∀x∈R)P(x)
“x P (x)” true when every instance of x makes P (x) true when plugged in

8.4 Sub topic 2: Existential Quantifier


“” reads “there exists”, “For at least one”, “For some one”.
There exist an x such that x>0.
(x) (x>0). The truth value depends on the interpretation
General format: (x) (P(x)).

8.5 Sub topic 3: Interpretation of expressions


(x)(y) Q(x,y) : x<y , This is true
(x) (x)Q(x,y) : x<y, This is false
(x)(y) Q(x,y) is read as: for every x there exist a y such that Q(x,y). If the domain is
Z, then Q(x,y) is the property

8.6 Sub topic 4: Well formed formulas(wffs)


These obey syntax rules
Expressions are built by combining predicates with quantifiers, symbols and logical

P(x) ((x) ∧) y . This is not a wff


connectives.

P(x) ∨ Q(y): wff but not quantifiable


(x)[P(x) → Q(x)]: The scope of the quantifier is P(x) → Q(x)
Grouping symbols help identify the scope of the quantifier

8.7 Sub topic 5: Negation of Quantified predicates


Universal negation: - x P(x )  x -P(x )
Existential negation: -x P(x )  x -P(x )

21
Activity 8a
Compute - x y x2  y.

We are trying to find the opposite of “every x admits a y greater or equal


to x’s square”.
The opposite is that “some x does not admit a y greater or equal to x’s
square”.
Algebraically, one just flips all quantifiers from  to  and vice versa, and
negates the interior propositional function.
In our case we get: x y ( x 2  y )  x y x 2 > y

Reading sources/links

 Kenneth H. Rosen. Discrete Mathematics and Its Applications, Seventh Edition, McGraw-Hill, 2012.
ISBN 978-0072899054. QA39.3 R67 2012 (LC).

Topic 9: RECURRENCE RELATIONS

9.1 Introduction
A recurrence relation for a sequence {an} is an equation that expresses an in terms of
one or more of the previous terms in the sequence, a0, a1, . . . , an−1 for all integers n 
n0 where n0 is a nonnegative integer. Sequence is called a solution of a recurrence
relation if its terms satisfy the recurrence relation.

9.2 Sub topic1: Solving recurrence relations


Find a solution to an = 5an−1 − 6an−2 with initial conditions a0 = 1, a1 = 4
The characteristic polynomial is
r2 − 5r + 6
Using the quadratic formula roots can be found;
r2 − 5r + 6 = (r − 2)(r − 3)
so r1 = 2, r2 = 3

9.3 Sub topic2: Application of recurrence relations in computing.

Algorithm Analysis Recurrence relations are frequently used to determine the time complexity
of recursive algorithms. The most common example is the analysis of the divide-and-conquer
strategy, which breaks a problem into smaller subproblems, solves them recursively, and
combines the results. The recurrence relation helps establish the overall time complexity.

 Example: Merge Sort follows the recurrence relation: Solving this using the Master
22
Theorem gives a complexity of .

Dynamic Programming Many problems in dynamic programming are defined recursively.


Recurrence relations help express these problems optimally by storing intermediate results to
avoid redundant computations.

 Example: Fibonacci sequence: Dynamic programming solves this efficiently using


memoization or tabulation.

Computational Complexity Recurrence relations help classify problems based on their


complexity. Many NP-hard problems, such as the Traveling Salesman Problem (TSP), rely on
recurrence relations to determine their feasibility in polynomial time.

Graph Algorithms Graph traversal algorithms, such as Depth-First Search (DFS) and Breadth-
First Search (BFS), often have recursive implementations whose efficiency is analyzed using
recurrence relations.

 Example: The Tower of Hanoi problem is a classic recursive problem defined by:
Solving this gives an exponential complexity of .

Computational Biology Recurrence relations are used in bioinformatics, particularly in


sequence alignment algorithms such as Needleman-Wunsch and Smith-Waterman, which
determine optimal alignments for DNA sequences.

Cryptography and Security Many cryptographic protocols, such as RSA encryption and
elliptic curve cryptography, rely on recurrence relations for key generation, encryption, and
decryption processes.

Activity 9a
Consider the recurrence relation an = 5an−1 − 6an−2 (2) with initial
conditions a0 = 1 and a1 = 4.
The characteristic equation is s2 − 5s + 6 = (s − 2)(s − 3) = 0.
Since the roots are s = 2 and s = 3,
any solution of (2) has the form an = 3n + 2n.
Therefore, a0 = + = 1 a1 = 3 + 2 = 4.
Solving this linear system, we get = 2 and = −1. The solution of (2) with
the given initial conditions is then an = 2 · 3n − 2n

23
m=30.

Reading sources/links

 Kenneth H. Rosen. Discrete Mathematics and Its Applications, Seventh Edition, McGraw-Hill, 2012.
ISBN 978-0072899054. QA39.3 R67 2012 (LC).

4.0 Module Summary/Conclusion


By the end of this module, students will be able to solve logic and proof techniques, set theory,
elementary number theory, functions and relations, graphs, trees, modeling computations and
abstract algebra expressions. Techniques of counting: permutations, combinations, recurrences,
algorithms are also covered to help students have a broader scope of real world problem
solving techniques.

4 PRACTICUUM
5 REVISION
6 EXAMINATION

24

You might also like