0% found this document useful (0 votes)
8 views42 pages

DS Lecture 12

Uploaded by

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

DS Lecture 12

Uploaded by

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

Discrete Structures

Mathematical Induction & Recursion


Lecture-12
What is induction?
• A method of proof

• It does not generate answers: it only


can prove them

• Three parts:
– Base case(s): show it is true
for one element
– Inductive hypothesis: assume
it is true for any given element
• Must be clearly labeled!!!
– Show that if it true for the next
highest element

2
Climbing an Infinite Ladder
Suppose we have an infinite ladder:
1. We can reach the first rung of the ladder.
2. If we can reach a particular rung of the
ladder, then we can reach the next rung.

From (1), we can reach the first rung.


Then by applying (2), we can reach the
second rung. Applying (2) again, the
third rung. And so on. We can apply (2)
any number of times to reach any
particular rung, no matter how high up.

This example motivates proof by


mathematical induction.
3
Mathematical induction is a form of mathematical proof.
Just because a rule, pattern, or formula seems to work
for several values of n, you cannot simply decide that it
is valid for all values of n without going through a
legitimate proof.

The Principle of Mathematical Induction


Let Pn be a statement involving the positive
integer n. If
1. P1 is true, and
2. the truth of Pk implies the truth of Pk+1 , for
every positive integer k,
then Pn must be true for all integers n.
4
Example - 1: Use mathematical induction to prove the
following formula.
Sn = 1 + 3 + 5 + 7 + . . . + (2n-1) = n2
First, we must show that the formula works for n = 1.
1. For n = 1
S1 = 1 = 1 2
The second part of mathematical induction has two steps.
1. The first step is to assume that the formula is valid for
some integer k.
2. The second step is to use this assumption to prove that
the formula is valid for the next integer, k + 1.
2. Assume Sk = 1 + 3 + 5 + 7 + . . . + (2k-1) = k2 is true,
show that Sk+1 = (k + 1)2 is true. 5
Sk = 1 + 3 + 5 + 7 + . . . + (2k-1)
Sk+1 = 1 + 3 + 5 + 7 + . . . + (2k – 1) + [2(k + 1) – 1]
= [1 + 3 + 5 + 7 + . . . +(2k – 1)] + (2k + 2 – 1)
= Sk + (2k + 1)
= k2 + 2k + 1
= (k + 1)2

6
Example - 2: Use mathematical induction to prove the
following formula.
𝑛 (𝑛+1 ) ( 2𝑛+1 )
Sn = 1 + 2 + 3 + 4 + + n =
2 2 2 2 ... 2
6
1. Show n = 1 is true.
1( 2) ( 3 )
Sn = 1 =
2
6
2. Assume that Sk is true.

Sk = 1 + 2 + 3 + 4 + + k =
2 2 2
𝑘2
( 𝑘+1 )
...
( 2 𝑘+12
)
6
( 𝑘+ 1 )( 𝑘+2 )( 2 𝑘+3 )
Show that Sk+1 = is true.
6
7
Sk+1 = (12 + 22 + 32 + 42 + . . . + k2) + (k + 1)2

k k 12k 1
 + (k + 1)2
6
2
𝑘 ( 𝑘+1 ) ( 2 𝑘+1 ) +6 ( 𝑘+1 ) Factor out a (k + 1)
¿
6
( 𝑘+1 ) [ 𝑘 ( 2 𝑘+ 1 ) +6 ( 𝑘+1 ) ]
¿
6
( 𝑘+1 ) [ 2𝑘 +7 𝑘+6 ] ( 𝒌+𝟏 )( 𝒌 +𝟐 ) ( 𝟐 𝒌+𝟑 )
2
¿ ¿
6 𝟔 8
Recursion
9
10
11
12
13
14
15
16
17
18
Discrete Mathematics in the
Real World

19
20
 Computers run software and store files.

 The software/files both stored as huge strings of 1s and 0s.

 Binary math is discrete mathematics.

21
22
Online Shopping
Encryption and decryption are part of
cryptography, which is part of discrete
mathematics. For example, secure
internet shopping uses public-key
cryptography.

23
Analog Clock
An Analog Clock has gears inside, and the
sizes/teeth needed for correct timekeeping are
determined using discrete math.

24
Dijkstra’s Algorithm and Google Maps

Google Maps uses discrete mathematics to


determine fastest driving routes and times.

25
Railway Planning
Railway planning uses discrete math: deciding
how to expand train rail lines, train timetable
scheduling, and scheduling crews and
equipment for train trips use both graph theory
and linear algebra.

26
27
Computer Graphics
Computer graphics (such as in video games) use
linear algebra in order to transform (move,
scale, change perspective) objects. That's true
for both applications like game development,
and for operating systems.

28
Smarter Phones for All
Cell Phone Communications: Making efficient use
of the broadcast spectrum for mobile phones
uses linear algebra and information theory.
Assigning frequencies so that there is no
interference with nearby phones can use graph
theory or can use discrete optimization.

29
Finding Friends on
Facebook
Graph theory can be used in speeding up
Facebook performance.

30
DNA Fragment Assembly
Graph theory is used in DNA sequencing.

31
Learning Discrete Mathematics
make you a better Programmer?
 One of the most important competences – that one must

have; as a program developer is to be able to choose the


right algorithms and data structures for the problem that the
program is supposed to solve.
 The importance of discrete mathematics lies in its central role

in the analysis of algorithms and in the fact that many


common data structures – and in particular graphs, trees, sets
and ordered sets – and their associated algorithms come from
the domain of discrete mathematics.
32
Why Proofs?
Why proofs? The analysis of an algorithm
requires one to carry out (or at the very least
be able to sketch) a proof of the correctness of
the algorithm and a proof of its complexity

33
Logic and Proofs
Programmers use logic. All the time. While
everyone has to think about the solution, a
formal study of logical thinking helps you
organize your thought process more efficiently.

34
Combinatorics
One cannot program without loops or recursion.
(I mean we could, but it wouldn't be very useful)
Getting a sense of the Mathematics behind
these very essential programming concepts help
you optimise your code.

35
Graphs
One cannot overestimate the importance of
graphs in CS today, what with the emergence
of social networks and the need to represent all
types of complex relationships between
entities. Learning Graphs can help you
visualise a lot of data structures better. Also,
there is a lot of room for better programming in
graphs. Having mathematical knowledge about
them is essential to do that.

36
Moral of the Story???
Discrete Math is needed to see mathematical

structures in the object you work with, and


understand their properties. This ability is
important for software engineers, data
scientists, security and financial analysts.
it is not a coincidence that math puzzles

are often used for interviews.

37
Problems Solved using Discrete Mathematics

1. The Foundations: Logic and Proofs


How can we represent English sentences so that a
computer can deal with them?
2. Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
How can we describe the relationship between
different set?
3. Algorithms
How can a list of integers be sorted so that the
integers are in increasing order?
4. Number Theory and Cryptography
How can we represent the even integer and odd
38 integer?
Problems Solved using Discrete Mathematics

5. Introduction and Recursion


How can we prove that there are infinitely many
prime numbers?
How can it be proved that a sorting algorithm
always correctly sorts a list?
6. Counting
How many valid Internet addresses are there?
How many ways can a password be chosen
following specific rules?
7. Discrete Probability
What is the probability of winning a particular

39
lottery?
Problems Solved using Discrete Mathematics
9. Relations
How can we deal with the relationships between
elements of sets
10. Graphs
Find the shortest tour that visits each of a group of
cities only once and then ends in the starting city.
11. Trees
Binary search tree
Huffman coding
12. Boolean Algebra
The circuits in computers and other electronic
devices have inputs, each of which is either a 0 or a
1
40 Modeling Computation
13.
Can a task be carried out using a computer? How can
Discrete Mathematics is a
Gateway Course
Topics in discrete mathematics will be important
in many courses that you will take in the future:
Computer Science: Computer Architecture, Data
Structures, Algorithms, Programming Languages,
Compilers, Computer Security, Databases, Artificial
Intelligence, Networking, Graphics, Game Design,
Theory of Computation, Game Theory, Network
Optimization ……
Other Disciplines: You may find concepts learned
here useful in courses in philosophy, economics,
linguistics, and other departments.

41
42

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