0% found this document useful (0 votes)
46 views74 pages

DS Lecture-1

Discrete Structures Lecture Slide 1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views74 pages

DS Lecture-1

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

MA - 210

Discrete Structures

Introduction
Lecture-1
Overview of this Lecture

• Course Administration

• What is it about?

• Course Themes, Goals, and Syllabus


Course Administration
Timings

Lecture Hours:

Wednesday/Thursday (α and Ω): 12:00 PM – 03:00 PM


08:30 AM – 11:30 AM

Location:
Online (MS Teams/Class Room)

Lecturer: Muhammad Tariq Javed


Office: Faculty Office (Room-05), 1st Floor, CPED
Phone: 051-9047-596
Email: [email protected]
Assessments

Homework (10%)
Quiz (15%)
Midterm (25%)
Final (50%)
Homework and Quiz

• Homework is very important. It is the best way for you to


learn the material.
• You can discuss the problems with your classmates, but all
work handed in should be original, written by you in
your own words.
• Homework should be handed in in class.
• 20% penalty for each day late.

• Most Probably Quiz will be announced a week


before BUT there will be NO Re-Take for Quiz
in any Case.
Textbook(1)

Discrete Mathematics and Its Applications


by Kenneth H. Rosen, 7th Edition

Use lecture notes as study guide.


Textbook(2)

Discrete Mathematics
by Richard Johnsonbaugh
7th or 8th Edition
Reference Book

Discrete Mathematics
by Edgar Goodaire and Michael Parmenter
3rd Edition.
Overview of this Lecture

Course Administration

What is MA-210 about?

Course Themes, Goals, and Syllabus


What is MA-210 about?

Continuous vs. Discrete Math


Why is it computer science/engineering?
Mathematical techniques for DM
What Are Discrete Structures?

Discrete math is mathematics that deals with discrete objects:


• Discrete Objects are those which are separated from (distinct from)
each other, such as integers, rational numbers, houses, people, etc.
Real numbers are not discrete.
• In this course, we’ll be concerned with objects such as integers,
propositions, sets, relations and functions, which are all discrete.
• We’ll learn concepts associated with them, their properties, and
relationships among them.
Discrete structures are:
– Theoretical basis of computer science
– A mathematical foundation that makes you think logically
– A prerequisite course to understand the fundamentals of programming
Discrete vs. Continuous Mathematics

Continuous Mathematics
It considers objects that vary continuously;
Example: analog wristwatch (separate hour, minute, and second hands).
From an analog watch perspective, between 1 :25 p.m. and 1 :26 p.m.
there are infinitely many possible different times as the second hand moves
around the watch face.

Real-number system --- core of continuous mathematics;


Continuous mathematics --- models and tools for analyzing real-world
phenomena that change smoothly over time. (Differential equations etc.)
Discrete vs. Continuous Mathematics

Discrete Mathematics
It considers objects that vary in a discrete way.
Example: digital wristwatch.
On a digital watch, there are only finitely many possible different times
between 1 :25 P.m. and 1:27 P.m. A digital watch does not show split
seconds: no time between 1 :25:03 and 1 :25:04. The watch moves from one
time to the next.
Integers --- core of discrete mathematics
Discrete mathematics --- models and tools for analyzing real-world
phenomena that change discretely over time and therefore ideal for studying
computer science – computers are digital! (numbers as finite bit strings; data
structures, all discrete! Historical aside: earliest computers were analogue.)
Discrete vs Continuous
What is MA-210 about?

Why is it computer science/engineering?


(examples)
Logic:
Hardware and software specifications

Formal: Input_wire_A
value in {0, 1}

One-bit Full Adder with


Example 1: Adder
Carry-In and Carry-Out

4-bit full adder


Example 2: System Specification:

–The router can send packets to the edge system only if it supports the new address space.
–For the router to support the new address space it’s necessary that the latest software release be installed.
–The router can send packets to the edge system if the latest software release is installed.
–The router does not support the new address space.

How to write these specifications in a formal way? Use Logic. Bart Selman
CS2800
Why Discrete Mathematics? (I)

• Computers use discrete structures to represent


and manipulate data.
• is the basic building block for becoming a
Computer Scientist
• Computer Science is not Programming
• Computer Science is not Software Engineering
• Edsger Dijkstra: “Computer Science is no more
about computers than Astronomy is about
telescopes.”
• Computer Science is about problem solving.
Why Discrete Mathematics? (II)

• Mathematics is at the heart of problem solving


• Defining a problem requires mathematical rigor
• Use and analysis of models, data structures,
algorithms requires a solid foundation of
mathematics
• To justify why a particular way of solving a
problem is correct or efficient (i.e., better than
another way) requires analysis with a well-
defined mathematical model.
Problem Solving requires mathematical rigor
(Accuracy, Objectivity)

• Your boss is not going to ask you to solve


– an MST (Minimal Spanning Tree) or
– a TSP (Travelling Salesperson Problem)
• Rarely will you encounter a problem in an
abstract setting
• However, he/she may ask you to build a rotation
of the company’s delivery trucks to minimize
fuel usage
• It is up to you to determine
– a proper model for representing the problem and
– a correct or efficient algorithm for solving it
Number Theory:
RSA and Public-key Cryptography

Alice and Bob have never met but they would like to
exchange a message. Eve would like to eavesdrop.
E.g. between you and the Bank of America.

They could come up with a good


encryption algorithm and exchange the
encryption key – but how to do it without
Eve getting it? (If Eve gets it, all security
is lost.)

CS folks found the solution:


public key encryption. Quite remarkable that is feasible.
Number Theory:
Public Key Encryption

RSA – Public Key Cryptosystem (why RSA?)


Uses modular arithmetic and large primes  Its security comes from the computational difficulty
of factoring large numbers.
RSA Approach
Encode:
C = Me (mod n)
M is the plaintext; C is ciphertext
n = pq with p and q large primes (e.g. 200 digits long!)
e is relative prime to (p-1)(q-1) Hmm??
Decode: What does this all mean??
d
How does this actually work?
C = M (mod pq) Not to worry. We’ll find out.
d is inverse of e modulo (p-1)(q-1)

The process of encrypting and decrypting a message


correctly results in the original message (and it’s fast!)
Graph Theory
Graphs and Networks

Many problems can be represented by a


graphical network representation.

•Examples:
– Distribution problems
– Routing problems Aside: finding the right
– Maximum flow problems problem representation
– Designing computer / phone / road networks is one of the key issues
– Equipment replacement
– And of course the Internet
in this course.
Networks are
New Science of Networks pervasive
Sub-Category Graph
No Threshold

Utility Patent network


1972-1999
(3 Million patents)
Gomes,Hopcroft,Lesser,Selman

Neural network of the


nematode worm C- elegans
(Strogatz, Watts)

NYS Electric
Power Grid Network of computer scientists
Cyber communities
(Thorp,Strogatz,Watts) ReferralWeb System
(Automatically discovered)
(Kautz and Selman)
Kleinberg et al
Applications of Networks
Physical analog Physical analog
Applications Flow
of nodes of arcs
phone exchanges,
Cables, fiber optic Voice messages,
Communication computers,
links, microwave Data,
systems transmission
relay links Video transmissions
facilities, satellites
Pumping stations Water, Gas, Oil,
Hydraulic systems Pipelines
Reservoirs, Lakes Hydraulic fluids
Integrated Gates, registers,
Wires Electrical current
computer circuits processors
Rods, Beams,
Mechanical systems Joints Heat, Energy
Springs
Passengers,
Intersections, Highways,
Transportation freight,
Airports, Airline routes
systems vehicles,
Rail yards Railbeds
operators
Example: Coloring a Map

How to color this map so that no two


adjacent regions have the same color?
Examples of Applications of
Graph Coloring
Scheduling of Final Exams

How can the final exams at UET be scheduled so that no student has
two exams at the same time? (Note not obvious this has anything to do
with graphs or graph coloring.)

Graph:
A vertex correspond to a course.
An edge between two vertices denotes that there is at least one common
student in the courses they represent.
Each time slot for a final exam is represented by a different color.

A coloring of the graph corresponds to a valid schedule of the exams.


Scheduling of Final Exams

1 1
Time Courses
Period
2 7 2 I 1,6
7
II 2
III 3,5
IV 4,7
6 3 6 3

5 4 5 4

What are the constraints between courses?


Find a valid coloring
Frequency Assignments

T.V. channels 2 through 13 are assigned to stations in North


America so that no two stations within 150 miles can operate
on the same channel. How can the assignment of channels
be modeled as a graph coloring?

• A vertex corresponds to one station


• There is a edge between two vertices if they are located within 150
miles of each other
• Coloring of graph --- corresponds to a valid assignment of channels;
each color represents a different channel.
Frequency Reuse in
Cellular Wireless Networks

Frequency reusing is the concept of using the same radio frequencies


within a given area, that are separated by considerable distance, with
minimal interference, to establish communication.

Frequency reuse offers the following benefits:


Allows communications within cell on a given frequency
Limits escaping power to adjacent cells
Allows re-use of frequencies in nearby cells
Uses same frequency for multiple conversations
10 to 50 frequencies per cell
Frequency Assignment Problems (FAPs)

 Cellular systems provider allocates frequencies from a


licensed spectrum.
 Constraints:
 For any cell, interference from nearby cells within an
acceptable minimum.
 For any cell, the frequency bandwidth allocated sufficient to
support the load in the cell.
 Objectives:
 Minimize the total bandwidth (or width of the spectrum)
allocated across all cells.
 Minimize call blocking probability.
 Minimize average interference.
Solving FAPs

 Since the programs are all integer programs, hard to solve in


general

 Can apply standard mathematical programming heuristics


 Branch and bound
 Cutting plane techniques
 Local search
 Simulated annealing
 Tabu search

 Some problems can be expressed as graph coloring problems


in specialized graphs
Formulating FAPs

 Can be expressed as mathematical programs


 Mostly linear
 Some non-linear (e.g., minimizing interference)

 Approach:
 Represent the cellular structure as a graph
 Each node represents a cell (center)
 Interference relationships represented by the graph edges
 Assigning a frequency same as assigning a fixed-width band
centered around the frequency
 Binary variables that indicate whether a (center) frequency is
assigned
Index Registers

In efficient compilers the execution of loops can be speeded up by


storing frequently used variables temporarily in registers in the
central processing unit, instead of the regular memory. For a given
loop, how many index registers are needed?

• Each vertex corresponds to a variable in the loop.


• An edge between two vertices denotes the fact that the corresponding
variables must be stored in registers at the same time during the
execution of the loop.
• Chromatic number of the graph gives the number of index registers
needed.
Example 2:
Traveling Salesman

Find a closed tour of minimum length visiting all the cities.

TSP  lots of applications:


Transportation related: scheduling deliveries
Many others: e.g., Scheduling of a machine to drill holes in a circuit board ; etc
13509 cities in the US

13508!= 1.4759774188460148199751342753208e+49936
The optimal tour!
Social Networks
3 Sample Graphs
Directed / Un-Directed Networks
Properties of Nodes
Measuring Centrality
Measuring Centrality
Course Themes, Goals, and Course Outline
Goals of MA-210
Introduce students to a range of mathematical tools from discrete
mathematics that are key in computer science

Mathematical Sophistication
How to write statements rigorously Practice works!
How to read and write theorems, lemmas, etc.
How to write rigorous proofs
Actually, only practice works!
Areas we will cover:
Logic and proofs Note: Learning to do proofs from
Set Theory watching the slides is like trying to
Number Theory learn to play tennis from watching
Counting and combinatorics
it on TV! So, do exercises!
Tentative Topics MA-210
Logic and Methods of Proof
Propositional Logic --- SAT as an encoding language!
Predicates and Quantifiers
Methods of Proofs
Number Theory
Modular arithmetic
RSA cryptosystems
Sets
Sets and Set operations
Functions
Counting
Basics of counting
Pigeonhole principle
Permutations and Combinations
Topics MA-210
Graphs and Trees
Graph terminology
Example of graph problems and algorithms:
graph coloring
TSP
shortest path
Min. spanning tree
Scenario I

• A limo company hires you/your company to write


a computer program to automate their work
• Task1
• In the first scenario, businesses request
– limos and drivers
– for a fixed period of time, specifying a start data/time and end
date/time
• The program must generate a schedule that uses the
minimum number of cars

Bart Selman
CS2800
Scenario II

• Task 2
– In the second scenario,
• the limo service allows customers to bid on a ride
• so that the highest bidder gets a limo when there aren’t enough
limos available
– The program should make a schedule that
• Is feasible (no limo is assigned to two or more customers at the
same time)
• While maximizing the total profit

Bart Selman
CS2800
Scenario III

• Task 3
– Here each customer
• is allowed to specify a time window for each car and
• bid different amounts for different “car bundles”
• The limo service must choose to accept the entire set of times
or reject it
– The program must again maximize profit

Bart Selman
CS2800
Bart Selman
CS2800
What’s your job?

• Build a mathematical model for each scenario


• Develop an algorithm for solving each task
• Prove that your solutions work
– Termination: Prove that your algorithms terminate
– Completeness: Prove that your algorithms find a
solution when there is one.
– Soundness: Prove that the solution of your algorithms
is always correct
– Optimality (of the solution): Prove that your algorithms
find the best solution (i.e., maximize profit)
– Efficiency, time & space complexity: Prove that your
algorithms finish before the end of life on earth

Bart Selman
CS2800
The goal of this course

• Give you the foundations that you will use in


future courses to solve these problems
– Task1 is easily (i.e., efficiently) solved by a greedy
algorithm
– Task2 can also be (almost) easily solved, but
requires a more involved technique, dynamic
programming
– Task3 is not efficiently solvable by any known
technique. It is believed today that to guarantee an
optimal solution, one needs to look at all
(exponentially many) possibilities Bart Selman
CS2800
As an example…

Find the most efficient route for the


parking-control officer, who travels on foot,
to check the meters in an area. Bart Selman
CS2800
The previous situation can be
represented by a graph

… in order to simplify the problem…

Bart Selman
CS2800
… and analyze the information…

…to optimize the most efficient route.

Bart Selman
CS2800
The Digital World
Identification numbers and codes are associated with
many aspects of our modern world.

This credit
card is a fake! Codabar

Add the digits in positions 1, 3, 5, 7, 9, 11, 13, and 15 and double


the result; Next, count the number of digits in those positions
that exceed 4 and add this to the total. Now add in the remaining
digits. The check digit is the number needed to bring this final
tally to a number that ends in 0.
(4+2+0+1+3+5+7+9) x 2 + 3 + (1+8+0+2+4+6+8) +
0 = 94
How Google Map Works?

• Google map works on the basis of Dijkstra's


algorithm
• Dijkstra's algorithm is an algorithm for finding
the shortest paths between nodes in a graph,
which may represent, for example, road
networks. As shown
How Google Map Works?
How Google Map Works?
How Google Map Works?
How Google Map Works?
How Google Map Works?
What google maps do?
What google maps do?
What google maps do?

3 1
1
4
2
2 1 3 4
3
3
What google maps do?

3 1
1
4
2
2 1 3 4
3
3
What google maps do?

3 1
1
4
2
2 1 3 4
3
3
What google maps do?

3 1
1
4
2
2 1 3 4
3
3
The END

You might also like