SlideShare a Scribd company logo
Programming for Data
Analysis
Week 4
Dr. Ferdin Joe John Joseph
Faculty of Information Technology
Thai – Nichi Institute of Technology, Bangkok
Today’s lesson
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
2
• Permutations
• Combinations
• Laboratory
Permutations
• A permutation of a set of distinct objects is an ordered arrangement
these objects.
• An ordered arrangement of r elements of a set is called an r-
permutation.
• The number of r-permutations of a set with n elements is denoted by
P(n,r).
A = {1,2,3,4} 2-permutations of A include 1,2; 2,1; 1,3; 2,3; etc…
Counting Permutations
• Using the product rule we can find P(n,r)
= n*(n-1)*(n-2)* …*(n-r+1)
= n!/(n-r)!
How many 2-permutations are there for the set {1,2,3,4}? P(4,2)
12
!2
!4
1*2
1*2*3*4
3*4 ===
Combinations
• An r-combination of elements of a set is an unordered selection of r
element from the set. (i.e., an r-combination is simply a subset of the
set with r elements).
Let A={1,2,3,4} 3-combinations of A are
{1,2,3}, {1,2,4}, {1,3,4}, {2,3,4}(same as {3,2,4})
• The number of r-combinations of a set with n distinct elements is
denoted by C(n,r).
Example
Let A = {1,2,3}
2-permutations of A are: 1,2 2,1 1,3 3,1 2,3 3,2
6 total.Order is important
2-combinations of A are: {1,2}, {1,3}, {2,3}
3 total. Order is not important
If we counted the number of permutations of each 2-
combination we could figure out P(3,2)!
How to compute C(n,r)
• To find P(n,r), we could first find C(n,r), then order
each subset of r elements to count the number of
different orderings. P(n,r) = C(n,r)P(r,r).
• So C(n,r) = P(n,r) / P(r,r)
)!(!
!
!)!(
)!(!
)!(
!
)!(
!
rnr
n
rrn
rrn
rr
r
rn
n
−
=
−
−
=
−
−
=
A club has 25 members.
• How many ways are there to choose four members of the club to
serve on an executive committee?
• Order not important
• C(25,4) = 25!/21!4! = 25*24*23*22/4*3*2*1 =25*23*22 = 12,650
• How many ways are there to choose a president, vice president,
secretary, and treasurer of the club?
• Order is important
• P(25,4) = 25!/21! = 303,600
The English alphabet contains 21 consonants and 5 vowels. How many
strings of six lower case letters of the English alphabet contain:
• exactly one vowel?
• exactly 2 vowels
• at least 1 vowel
• at least 2 vowels
The English alphabet contains 21 consonants and 5 vowels. How many
strings of six lower case letters of the English alphabet contain:
• exactly one vowel?
Note that strings can have repeated letters!
We need to choose the position for the vowel
C(6,1) = 6!/1!5! This can be done 6 ways.
Choose which vowel to use.
This can be done in 5 ways.
Each of the other 5 positions can contain any of the 21 consonants (not distinct).
There are 215 ways to fill the rest of the string.
6*5*215
The English alphabet contains 21 consonants and 5 vowels. How many
strings of six lower case letters of the English alphabet contain:
• exactly 2 vowels?
Choose position for the vowels.
C(6,2) = 6!/2!4! = 15
Choose the two vowels.
5 choices for each of 2 positions = 52
Each of the other 4 positions can contain any of 21 consonants.
214
15*52*214
The English alphabet contains 21 consonants and 5 vowels. How many
strings of six lower case letters of the English alphabet contain:
• at least 1 vowel
Count the number of strings with no vowels and subtract this from the
total number of strings.
266 - 216
The English alphabet contains 21 consonants and 5 vowels. How many
strings of six lower case letters of the English alphabet contain:
• at least 2 vowels
Compute total number of strings and subtract number of strings with
no vowels and the number of strings with exactly 1 vowel.
266 - 216 - 6*5*215
Corollary 1: Let n and r be nonnegative integers with r  n.
Then C(n,r) = C(n,n-r)
Proof:
C(n,r) = n!/r!(n-r)!
C(n,n-r) = n!/(n-r)!(n-(n-r))! = n!/r!(n-r)!
Binomial Coefficient
Another notation for C(n,r) is . This number is
also called a binomial coefficient.
These numbers occur as coefficients in the expansions
of powers of binomial expressions such as (a+b)n.
n
r


 

Pascal’s Identity
Let n and k be positive integers with n  k. Then
C(n+1,k) = C(n, k-1) + C(n,k).
Proof:
),1(
)!1(!
)!1(
)!1(!
)1(!
)!1(!
)1(!
)!)(1(!
!)1(
)!)(1()!1(
!
)!(!
!
)!1()!1(
!
),()1,(
knC
knk
n
knk
nn
knk
knkn
knknk
nkn
knknkk
kn
knk
n
knk
n
knCknC
+=
−+
+
=
−+
+
=
−+
+−+
=
−+−
+−
+
−+−−
=
−
+
+−−
=
+−
17
Combinatorics
• Count the number of ways to put things together
into various combinations.
e.g. If a password is 6-8 letters and/or digits, how many
passwords can there be?
• Two main rules:
• Sum rule
• Product rule
18
Sum Rule
• Let us consider two tasks:
• m is the number of ways to do task 1
• n is the number of ways to do task 2
• Tasks are independent of each other, i.e.,
• Performing task 1 does not accomplish task 2 and vice versa.
• Sum rule: the number of ways that “either task 1
or task 2 can be done, but not both”, is m+n.
• Generalizes to multiple tasks ...
19
Example
• A student can choose a computer project from one of three lists. The three lists
contain 23, 15, and 19 possible projects respectively. How many possible projects
are there to choose from?
20
Set Theoretic Version
• If A is the set of ways to do task 1, and B the set of ways to do task 2,
and if A and B are disjoint, then:
“the ways to do either task 1 or 2 are
AB, and |AB|=|A|+|B|”
21
Product Rule
• Let us consider two tasks:
• m is the number of ways to do task 1
• n is the number of ways to do task 2
• Tasks are independent of each other, i.e.,
• Performing task 1does not accomplish task 2 and vice versa.
• Product rule: the number of ways that “both tasks
1 and 2 can be done” in mn.
• Generalizes to multiple tasks ...
22
Example
• The chairs of an auditorium are to be labeled with a letter and a positive integer
not to exceed 100. What is the largest number of chairs that can be labeled
differently?
23
Set Theoretic Version
• If A is the set of ways to do task 1, and B the set of ways to do task 2,
and if A and B are disjoint, then:
• The ways to do both task 1 and 2 can be represented as AB, and
|AB|=|A|·|B|
24
More Examples
• How many different bit strings are there of length seven?
25
More Examples
• Suppose that either a member of the CS faculty or a student who is a CS major
can be on a university committee. How many different choices are there if there
are 37 CS faculty and 83 CS majors ?
26
More Examples
• How many different license plates are available if each plate contains
a sequence of three letters followed by three digits?
27
More Examples
• What is the number of different subsets of a finite set S ?
28
Example Using Both Rules
• Each user on a computer system has a password, which is six to eight characters
long where each character is an uppercase letter or a digit. Each password must
contain at least one digit. How many possible passwords are there?
29
IP Address Example
(Internet Protocol vers. 4)
• Main computer addresses are in one of 3 types:
• Class A: address contains a 7-bit “netid” ≠ 17, and a 24-bit “hostid”
• Class B: address has a 14-bit netid and a 16-bit hostid.
• Class C: address has 21-bit netid and an 8-bit hostid.
• Hostids that are all 0s or all 1s are not allowed.
• How many valid computer addresses are there?
30
Example Using Both Rules:
IP address solution
• (# addrs)
= (# class A) + (# class B) + (# class C)
(by sum rule)
• # class A = (# valid netids)·(# valid hostids)
(by product rule)
• (# valid class A netids) = 27 − 1 = 127.
• (# valid class A hostids) = 224 − 2 = 16,777,214.
• Continuing in this fashion we find the answer is:
3,737,091,842 (3.7 billion IP addresses)
31
Inclusion-Exclusion Principle
(relates to the “sum rule”)
• Suppose that km of the ways of doing task 1 also simultaneously
accomplishes task 2. (And thus are also ways of doing task 2.)
• Then the number of ways to accomplish “Do either task 1 or task 2” is
m+n−k.
• Set theory: If A and B are not disjoint, then |AB|=|A|+|B|−|AB|.
32
Example
• How many strings of length eight either start with a 1 bit or end with
the two bit string 00?
33
More Examples
• Hypothetical rules for passwords:
• Passwords must be 2 characters long.
• Each password must be a letter a-z, a digit 0-9, or one of the 10 punctuation
characters !@#$%^&*().
• Each password must contain at least 1 digit or punctuation character.
34
Sol. Cont’d
• A legal password has a digit or puctuation
character in position 1 or position 2.
• These cases overlap, so the principle applies.
• (# of passwords w. OK symbol in
position #1) = (10+10)·(10+10+26)
• (# w. OK sym. in pos. #2): also 20·46
• (# w. OK sym both places): 20·20
• Answer: 920+920−400 = 1,440
35
Example
• How many ways are there to select a third-prize winner from 100
different people who have entered a contest?
36
More Examples
• A terrorist has planted an armed nuclear bomb in your city, and it is
your job to disable it by cutting wires to the trigger device.
• There are 10 wires to the device.
• If you cut exactly the right three wires, in exactly the right order, you
will disable the bomb, otherwise it will explode!
• If the wires all look the same, what are your chances of survival?
37
More Examples
• A terrorist has planted an armed nuclear bomb in your city, and it is
your job to disable it by cutting wires to the trigger device.
• There are 10 wires to the device.
• If you cut exactly the right three wires, in exactly the right order, you
will disable the bomb, otherwise it will explode!
• If the wires all look the same, what are your chances of survival?
P(10,3) = 10·9·8 = 720,
so there is a 1 in 720 chance
that you’ll survive!
38
More Examples
• How many permutations of the letters ABCDEFG contain the string
ABC?
39
More Examples
• How many ways are there to select a committee to develop a discrete
mathematics course if the committee is to consist of 3 faculty members from the
Math department and 4 from the CS department, if there are 9 faculty members
from Math and 11 from CS?
40
Combinations with Repetition
• The number of r-combinations from a set with n
elements when repetition of elements is allowed
are C(n+r-1,r)
41
Combinations with Repetition
Example: How many ways are there to select 5 bills from a cash box
containing $1 bills, $2 bills, $5 bills, $10 bills, $20 bills, $50 bills, and
$100 bills? Assume that the order in which bills are chosen does not
matter and there are at least 5 bills of each type.
DSA 207 – Permutation and combination
• Create pivot table to find month wise average of internal and external
temperature, humidity and carbon monoxide levels in the fish data
• Visualize the binning of humidity levels in fish data over a particular time of
a day in a month. Do it with the following
• 1. Qcut
• 2. Cut
• 3. Naming Bins
• Solve two combinatorics problem
Faculty of Information Technology, Thai - Nichi Institute of
Technology, Bangkok
42

More Related Content

What's hot

Blockchain Technology - Week 5 - Cryptography and Steganography
Blockchain Technology - Week 5 - Cryptography and SteganographyBlockchain Technology - Week 5 - Cryptography and Steganography
Blockchain Technology - Week 5 - Cryptography and Steganography
Ferdin Joe John Joseph PhD
 
Blockchain Technology - Week 2 - Blockchain Terminologies
Blockchain Technology - Week 2 - Blockchain TerminologiesBlockchain Technology - Week 2 - Blockchain Terminologies
Blockchain Technology - Week 2 - Blockchain Terminologies
Ferdin Joe John Joseph PhD
 
Blockchain Technology - Week 4 - Hyperledger and Smart Contracts
Blockchain Technology - Week 4 - Hyperledger and Smart ContractsBlockchain Technology - Week 4 - Hyperledger and Smart Contracts
Blockchain Technology - Week 4 - Hyperledger and Smart Contracts
Ferdin Joe John Joseph PhD
 
Data Wrangling Week 4
Data Wrangling Week 4Data Wrangling Week 4
Data Wrangling Week 4
Ferdin Joe John Joseph PhD
 
Data wrangling week 10
Data wrangling week 10Data wrangling week 10
Data wrangling week 10
Ferdin Joe John Joseph PhD
 
DSA 103 Object Oriented Programming :: Week 1
DSA 103 Object Oriented Programming :: Week 1DSA 103 Object Oriented Programming :: Week 1
DSA 103 Object Oriented Programming :: Week 1
Ferdin Joe John Joseph PhD
 
RCA Rolling cycle amplification is a isothermal
RCA Rolling cycle amplification is a isothermalRCA Rolling cycle amplification is a isothermal
RCA Rolling cycle amplification is a isothermal
Moksha34
 
Stockfish NNUEプロジェクト - 第25回ゲームプログラミングワークショップ (GPW-20)
Stockfish NNUEプロジェクト - 第25回ゲームプログラミングワークショップ (GPW-20)Stockfish NNUEプロジェクト - 第25回ゲームプログラミングワークショップ (GPW-20)
Stockfish NNUEプロジェクト - 第25回ゲームプログラミングワークショップ (GPW-20)
Hisayori Noda
 
深層学習(講談社)のまとめ(1章~2章)
深層学習(講談社)のまとめ(1章~2章)深層学習(講談社)のまとめ(1章~2章)
深層学習(講談社)のまとめ(1章~2章)
okku apot
 
在宅で学ぶ大学生と教職員のための情報収集法&大学図書館リモート活用法
在宅で学ぶ大学生と教職員のための情報収集法&大学図書館リモート活用法在宅で学ぶ大学生と教職員のための情報収集法&大学図書館リモート活用法
在宅で学ぶ大学生と教職員のための情報収集法&大学図書館リモート活用法
takanoriumezawa
 
0から理解するニューラルネットアーキテクチャサーチ(NAS)
0から理解するニューラルネットアーキテクチャサーチ(NAS)0から理解するニューラルネットアーキテクチャサーチ(NAS)
0から理解するニューラルネットアーキテクチャサーチ(NAS)
MasanoriSuganuma
 

What's hot (11)

Blockchain Technology - Week 5 - Cryptography and Steganography
Blockchain Technology - Week 5 - Cryptography and SteganographyBlockchain Technology - Week 5 - Cryptography and Steganography
Blockchain Technology - Week 5 - Cryptography and Steganography
 
Blockchain Technology - Week 2 - Blockchain Terminologies
Blockchain Technology - Week 2 - Blockchain TerminologiesBlockchain Technology - Week 2 - Blockchain Terminologies
Blockchain Technology - Week 2 - Blockchain Terminologies
 
Blockchain Technology - Week 4 - Hyperledger and Smart Contracts
Blockchain Technology - Week 4 - Hyperledger and Smart ContractsBlockchain Technology - Week 4 - Hyperledger and Smart Contracts
Blockchain Technology - Week 4 - Hyperledger and Smart Contracts
 
Data Wrangling Week 4
Data Wrangling Week 4Data Wrangling Week 4
Data Wrangling Week 4
 
Data wrangling week 10
Data wrangling week 10Data wrangling week 10
Data wrangling week 10
 
DSA 103 Object Oriented Programming :: Week 1
DSA 103 Object Oriented Programming :: Week 1DSA 103 Object Oriented Programming :: Week 1
DSA 103 Object Oriented Programming :: Week 1
 
RCA Rolling cycle amplification is a isothermal
RCA Rolling cycle amplification is a isothermalRCA Rolling cycle amplification is a isothermal
RCA Rolling cycle amplification is a isothermal
 
Stockfish NNUEプロジェクト - 第25回ゲームプログラミングワークショップ (GPW-20)
Stockfish NNUEプロジェクト - 第25回ゲームプログラミングワークショップ (GPW-20)Stockfish NNUEプロジェクト - 第25回ゲームプログラミングワークショップ (GPW-20)
Stockfish NNUEプロジェクト - 第25回ゲームプログラミングワークショップ (GPW-20)
 
深層学習(講談社)のまとめ(1章~2章)
深層学習(講談社)のまとめ(1章~2章)深層学習(講談社)のまとめ(1章~2章)
深層学習(講談社)のまとめ(1章~2章)
 
在宅で学ぶ大学生と教職員のための情報収集法&大学図書館リモート活用法
在宅で学ぶ大学生と教職員のための情報収集法&大学図書館リモート活用法在宅で学ぶ大学生と教職員のための情報収集法&大学図書館リモート活用法
在宅で学ぶ大学生と教職員のための情報収集法&大学図書館リモート活用法
 
0から理解するニューラルネットアーキテクチャサーチ(NAS)
0から理解するニューラルネットアーキテクチャサーチ(NAS)0から理解するニューラルネットアーキテクチャサーチ(NAS)
0から理解するニューラルネットアーキテクチャサーチ(NAS)
 

Similar to Programming for Data Analysis: Week 4

Combinatorics
CombinatoricsCombinatorics
Combinatorics
Rafay Farooq
 
Number system
Number systemNumber system
Number system
Diksha Shivpure
 
Combinatorics.ppt
Combinatorics.pptCombinatorics.ppt
Combinatorics.ppt
ssuserdc5a3d
 
Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Q...
Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Q...Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Q...
Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Q...
Mahbubur Rahman
 
Unit-1 Basic Concept of Algorithm.pptx
Unit-1 Basic Concept of Algorithm.pptxUnit-1 Basic Concept of Algorithm.pptx
Unit-1 Basic Concept of Algorithm.pptx
ssuser01e301
 
Brief introduction to Algorithm analysis
Brief introduction to Algorithm analysis Brief introduction to Algorithm analysis
Brief introduction to Algorithm analysis
Anantha Ramu
 
CH4__crypto.pptx
CH4__crypto.pptxCH4__crypto.pptx
CH4__crypto.pptx
Mohammad512578
 
rs_1.pptx
rs_1.pptxrs_1.pptx
rs_1.pptx
MaddulaCharishma
 
tutorial5.ppt
tutorial5.ppttutorial5.ppt
tutorial5.ppt
jvjfvvoa
 
X13Permutations.ppt
X13Permutations.pptX13Permutations.ppt
X13Permutations.ppt
Glaidz Rufino
 
Pre-Cal 40S May 4, 2009
Pre-Cal 40S May 4, 2009Pre-Cal 40S May 4, 2009
Pre-Cal 40S May 4, 2009
Darren Kuropatwa
 
Module 1 solving inequalities notes
Module 1 solving inequalities notesModule 1 solving inequalities notes
Module 1 solving inequalities notes
Michelle Barnhill
 
COMBINATORICS.ppt
COMBINATORICS.pptCOMBINATORICS.ppt
COMBINATORICS.ppt
svhnkrishnakumari
 
Exercises for pupils in primary education(0 4)-en
Exercises for pupils in primary education(0 4)-enExercises for pupils in primary education(0 4)-en
Exercises for pupils in primary education(0 4)-en
Georgeta Manafu
 
counting techniques
counting techniquescounting techniques
counting techniques
Unsa Shakir
 
Successful Minds,Making Mathematics number patterns &sequences Simple.
Successful Minds,Making Mathematics number patterns &sequences Simple.Successful Minds,Making Mathematics number patterns &sequences Simple.
Successful Minds,Making Mathematics number patterns &sequences Simple.
Thato Barry
 
Ebook 1
Ebook 1Ebook 1
Ebook 1
thato barry
 
math.pdf
math.pdfmath.pdf
math.pdf
JcKingz
 
Lecture 3 (algebraic expressions)
Lecture 3 (algebraic expressions)Lecture 3 (algebraic expressions)
Lecture 3 (algebraic expressions)
HarithaRanasinghe
 
4
44

Similar to Programming for Data Analysis: Week 4 (20)

Combinatorics
CombinatoricsCombinatorics
Combinatorics
 
Number system
Number systemNumber system
Number system
 
Combinatorics.ppt
Combinatorics.pptCombinatorics.ppt
Combinatorics.ppt
 
Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Q...
Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Q...Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Q...
Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Q...
 
Unit-1 Basic Concept of Algorithm.pptx
Unit-1 Basic Concept of Algorithm.pptxUnit-1 Basic Concept of Algorithm.pptx
Unit-1 Basic Concept of Algorithm.pptx
 
Brief introduction to Algorithm analysis
Brief introduction to Algorithm analysis Brief introduction to Algorithm analysis
Brief introduction to Algorithm analysis
 
CH4__crypto.pptx
CH4__crypto.pptxCH4__crypto.pptx
CH4__crypto.pptx
 
rs_1.pptx
rs_1.pptxrs_1.pptx
rs_1.pptx
 
tutorial5.ppt
tutorial5.ppttutorial5.ppt
tutorial5.ppt
 
X13Permutations.ppt
X13Permutations.pptX13Permutations.ppt
X13Permutations.ppt
 
Pre-Cal 40S May 4, 2009
Pre-Cal 40S May 4, 2009Pre-Cal 40S May 4, 2009
Pre-Cal 40S May 4, 2009
 
Module 1 solving inequalities notes
Module 1 solving inequalities notesModule 1 solving inequalities notes
Module 1 solving inequalities notes
 
COMBINATORICS.ppt
COMBINATORICS.pptCOMBINATORICS.ppt
COMBINATORICS.ppt
 
Exercises for pupils in primary education(0 4)-en
Exercises for pupils in primary education(0 4)-enExercises for pupils in primary education(0 4)-en
Exercises for pupils in primary education(0 4)-en
 
counting techniques
counting techniquescounting techniques
counting techniques
 
Successful Minds,Making Mathematics number patterns &sequences Simple.
Successful Minds,Making Mathematics number patterns &sequences Simple.Successful Minds,Making Mathematics number patterns &sequences Simple.
Successful Minds,Making Mathematics number patterns &sequences Simple.
 
Ebook 1
Ebook 1Ebook 1
Ebook 1
 
math.pdf
math.pdfmath.pdf
math.pdf
 
Lecture 3 (algebraic expressions)
Lecture 3 (algebraic expressions)Lecture 3 (algebraic expressions)
Lecture 3 (algebraic expressions)
 
4
44
4
 

More from Ferdin Joe John Joseph PhD

Invited Talk DGTiCon 2022
Invited Talk DGTiCon 2022Invited Talk DGTiCon 2022
Invited Talk DGTiCon 2022
Ferdin Joe John Joseph PhD
 
Week 12: Cloud AI- DSA 441 Cloud Computing
Week 12: Cloud AI- DSA 441 Cloud ComputingWeek 12: Cloud AI- DSA 441 Cloud Computing
Week 12: Cloud AI- DSA 441 Cloud Computing
Ferdin Joe John Joseph PhD
 
Week 11: Cloud Native- DSA 441 Cloud Computing
Week 11: Cloud Native- DSA 441 Cloud ComputingWeek 11: Cloud Native- DSA 441 Cloud Computing
Week 11: Cloud Native- DSA 441 Cloud Computing
Ferdin Joe John Joseph PhD
 
Week 10: Cloud Security- DSA 441 Cloud Computing
Week 10: Cloud Security- DSA 441 Cloud ComputingWeek 10: Cloud Security- DSA 441 Cloud Computing
Week 10: Cloud Security- DSA 441 Cloud Computing
Ferdin Joe John Joseph PhD
 
Week 9: Relational Database Service Alibaba Cloud- DSA 441 Cloud Computing
Week 9: Relational Database Service Alibaba Cloud- DSA 441 Cloud ComputingWeek 9: Relational Database Service Alibaba Cloud- DSA 441 Cloud Computing
Week 9: Relational Database Service Alibaba Cloud- DSA 441 Cloud Computing
Ferdin Joe John Joseph PhD
 
Week 7: Object Storage Service Alibaba Cloud- DSA 441 Cloud Computing
Week 7: Object Storage Service Alibaba Cloud- DSA 441 Cloud ComputingWeek 7: Object Storage Service Alibaba Cloud- DSA 441 Cloud Computing
Week 7: Object Storage Service Alibaba Cloud- DSA 441 Cloud Computing
Ferdin Joe John Joseph PhD
 
Week 6: Server Load Balancer and Auto Scaling Alibaba Cloud- DSA 441 Cloud Co...
Week 6: Server Load Balancer and Auto Scaling Alibaba Cloud- DSA 441 Cloud Co...Week 6: Server Load Balancer and Auto Scaling Alibaba Cloud- DSA 441 Cloud Co...
Week 6: Server Load Balancer and Auto Scaling Alibaba Cloud- DSA 441 Cloud Co...
Ferdin Joe John Joseph PhD
 
Week 5: Elastic Compute Service (ECS) with Alibaba Cloud- DSA 441 Cloud Compu...
Week 5: Elastic Compute Service (ECS) with Alibaba Cloud- DSA 441 Cloud Compu...Week 5: Elastic Compute Service (ECS) with Alibaba Cloud- DSA 441 Cloud Compu...
Week 5: Elastic Compute Service (ECS) with Alibaba Cloud- DSA 441 Cloud Compu...
Ferdin Joe John Joseph PhD
 
Week 4: Big Data and Hadoop in Alibaba Cloud - DSA 441 Cloud Computing
Week 4: Big Data and Hadoop in Alibaba Cloud - DSA 441 Cloud ComputingWeek 4: Big Data and Hadoop in Alibaba Cloud - DSA 441 Cloud Computing
Week 4: Big Data and Hadoop in Alibaba Cloud - DSA 441 Cloud Computing
Ferdin Joe John Joseph PhD
 
Week 3: Virtual Private Cloud, On Premise, IaaS, PaaS, SaaS - DSA 441 Cloud C...
Week 3: Virtual Private Cloud, On Premise, IaaS, PaaS, SaaS - DSA 441 Cloud C...Week 3: Virtual Private Cloud, On Premise, IaaS, PaaS, SaaS - DSA 441 Cloud C...
Week 3: Virtual Private Cloud, On Premise, IaaS, PaaS, SaaS - DSA 441 Cloud C...
Ferdin Joe John Joseph PhD
 
Week 2: Virtualization and VM Ware - DSA 441 Cloud Computing
Week 2: Virtualization and VM Ware - DSA 441 Cloud ComputingWeek 2: Virtualization and VM Ware - DSA 441 Cloud Computing
Week 2: Virtualization and VM Ware - DSA 441 Cloud Computing
Ferdin Joe John Joseph PhD
 
Week 1: Introduction to Cloud Computing - DSA 441 Cloud Computing
Week 1: Introduction to Cloud Computing - DSA 441 Cloud ComputingWeek 1: Introduction to Cloud Computing - DSA 441 Cloud Computing
Week 1: Introduction to Cloud Computing - DSA 441 Cloud Computing
Ferdin Joe John Joseph PhD
 
Sept 6 2021 BTech Artificial Intelligence and Data Science curriculum
Sept 6 2021 BTech Artificial Intelligence and Data Science curriculumSept 6 2021 BTech Artificial Intelligence and Data Science curriculum
Sept 6 2021 BTech Artificial Intelligence and Data Science curriculum
Ferdin Joe John Joseph PhD
 
Hadoop in Alibaba Cloud
Hadoop in Alibaba CloudHadoop in Alibaba Cloud
Hadoop in Alibaba Cloud
Ferdin Joe John Joseph PhD
 
Cloud Computing Essentials in Alibaba Cloud
Cloud Computing Essentials in Alibaba CloudCloud Computing Essentials in Alibaba Cloud
Cloud Computing Essentials in Alibaba Cloud
Ferdin Joe John Joseph PhD
 
Transforming deep into transformers – a computer vision approach
Transforming deep into transformers – a computer vision approachTransforming deep into transformers – a computer vision approach
Transforming deep into transformers – a computer vision approach
Ferdin Joe John Joseph PhD
 
Week 8: Programming for Data Analysis
Week 8: Programming for Data AnalysisWeek 8: Programming for Data Analysis
Week 8: Programming for Data Analysis
Ferdin Joe John Joseph PhD
 
Week2: Programming for Data Analysis
Week2: Programming for Data AnalysisWeek2: Programming for Data Analysis
Week2: Programming for Data Analysis
Ferdin Joe John Joseph PhD
 
Deep learning - Introduction
Deep learning - IntroductionDeep learning - Introduction
Deep learning - Introduction
Ferdin Joe John Joseph PhD
 
Data wrangling week 11
Data wrangling week 11Data wrangling week 11
Data wrangling week 11
Ferdin Joe John Joseph PhD
 

More from Ferdin Joe John Joseph PhD (20)

Invited Talk DGTiCon 2022
Invited Talk DGTiCon 2022Invited Talk DGTiCon 2022
Invited Talk DGTiCon 2022
 
Week 12: Cloud AI- DSA 441 Cloud Computing
Week 12: Cloud AI- DSA 441 Cloud ComputingWeek 12: Cloud AI- DSA 441 Cloud Computing
Week 12: Cloud AI- DSA 441 Cloud Computing
 
Week 11: Cloud Native- DSA 441 Cloud Computing
Week 11: Cloud Native- DSA 441 Cloud ComputingWeek 11: Cloud Native- DSA 441 Cloud Computing
Week 11: Cloud Native- DSA 441 Cloud Computing
 
Week 10: Cloud Security- DSA 441 Cloud Computing
Week 10: Cloud Security- DSA 441 Cloud ComputingWeek 10: Cloud Security- DSA 441 Cloud Computing
Week 10: Cloud Security- DSA 441 Cloud Computing
 
Week 9: Relational Database Service Alibaba Cloud- DSA 441 Cloud Computing
Week 9: Relational Database Service Alibaba Cloud- DSA 441 Cloud ComputingWeek 9: Relational Database Service Alibaba Cloud- DSA 441 Cloud Computing
Week 9: Relational Database Service Alibaba Cloud- DSA 441 Cloud Computing
 
Week 7: Object Storage Service Alibaba Cloud- DSA 441 Cloud Computing
Week 7: Object Storage Service Alibaba Cloud- DSA 441 Cloud ComputingWeek 7: Object Storage Service Alibaba Cloud- DSA 441 Cloud Computing
Week 7: Object Storage Service Alibaba Cloud- DSA 441 Cloud Computing
 
Week 6: Server Load Balancer and Auto Scaling Alibaba Cloud- DSA 441 Cloud Co...
Week 6: Server Load Balancer and Auto Scaling Alibaba Cloud- DSA 441 Cloud Co...Week 6: Server Load Balancer and Auto Scaling Alibaba Cloud- DSA 441 Cloud Co...
Week 6: Server Load Balancer and Auto Scaling Alibaba Cloud- DSA 441 Cloud Co...
 
Week 5: Elastic Compute Service (ECS) with Alibaba Cloud- DSA 441 Cloud Compu...
Week 5: Elastic Compute Service (ECS) with Alibaba Cloud- DSA 441 Cloud Compu...Week 5: Elastic Compute Service (ECS) with Alibaba Cloud- DSA 441 Cloud Compu...
Week 5: Elastic Compute Service (ECS) with Alibaba Cloud- DSA 441 Cloud Compu...
 
Week 4: Big Data and Hadoop in Alibaba Cloud - DSA 441 Cloud Computing
Week 4: Big Data and Hadoop in Alibaba Cloud - DSA 441 Cloud ComputingWeek 4: Big Data and Hadoop in Alibaba Cloud - DSA 441 Cloud Computing
Week 4: Big Data and Hadoop in Alibaba Cloud - DSA 441 Cloud Computing
 
Week 3: Virtual Private Cloud, On Premise, IaaS, PaaS, SaaS - DSA 441 Cloud C...
Week 3: Virtual Private Cloud, On Premise, IaaS, PaaS, SaaS - DSA 441 Cloud C...Week 3: Virtual Private Cloud, On Premise, IaaS, PaaS, SaaS - DSA 441 Cloud C...
Week 3: Virtual Private Cloud, On Premise, IaaS, PaaS, SaaS - DSA 441 Cloud C...
 
Week 2: Virtualization and VM Ware - DSA 441 Cloud Computing
Week 2: Virtualization and VM Ware - DSA 441 Cloud ComputingWeek 2: Virtualization and VM Ware - DSA 441 Cloud Computing
Week 2: Virtualization and VM Ware - DSA 441 Cloud Computing
 
Week 1: Introduction to Cloud Computing - DSA 441 Cloud Computing
Week 1: Introduction to Cloud Computing - DSA 441 Cloud ComputingWeek 1: Introduction to Cloud Computing - DSA 441 Cloud Computing
Week 1: Introduction to Cloud Computing - DSA 441 Cloud Computing
 
Sept 6 2021 BTech Artificial Intelligence and Data Science curriculum
Sept 6 2021 BTech Artificial Intelligence and Data Science curriculumSept 6 2021 BTech Artificial Intelligence and Data Science curriculum
Sept 6 2021 BTech Artificial Intelligence and Data Science curriculum
 
Hadoop in Alibaba Cloud
Hadoop in Alibaba CloudHadoop in Alibaba Cloud
Hadoop in Alibaba Cloud
 
Cloud Computing Essentials in Alibaba Cloud
Cloud Computing Essentials in Alibaba CloudCloud Computing Essentials in Alibaba Cloud
Cloud Computing Essentials in Alibaba Cloud
 
Transforming deep into transformers – a computer vision approach
Transforming deep into transformers – a computer vision approachTransforming deep into transformers – a computer vision approach
Transforming deep into transformers – a computer vision approach
 
Week 8: Programming for Data Analysis
Week 8: Programming for Data AnalysisWeek 8: Programming for Data Analysis
Week 8: Programming for Data Analysis
 
Week2: Programming for Data Analysis
Week2: Programming for Data AnalysisWeek2: Programming for Data Analysis
Week2: Programming for Data Analysis
 
Deep learning - Introduction
Deep learning - IntroductionDeep learning - Introduction
Deep learning - Introduction
 
Data wrangling week 11
Data wrangling week 11Data wrangling week 11
Data wrangling week 11
 

Recently uploaded

一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
nuttdpt
 
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
bopyb
 
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
74nqk8xf
 
The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
javier ramirez
 
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
v7oacc3l
 
Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......
Sachin Paul
 
Learn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queriesLearn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queries
manishkhaire30
 
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
Social Samosa
 
Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
Roger Valdez
 
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Aggregage
 
办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样
办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样
办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样
apvysm8
 
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging DataPredictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Kiwi Creative
 
Natural Language Processing (NLP), RAG and its applications .pptx
Natural Language Processing (NLP), RAG and its applications .pptxNatural Language Processing (NLP), RAG and its applications .pptx
Natural Language Processing (NLP), RAG and its applications .pptx
fkyes25
 
一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理
一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理
一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理
74nqk8xf
 
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
g4dpvqap0
 
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
ahzuo
 
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
g4dpvqap0
 
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
u86oixdj
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
slg6lamcq
 
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
nuttdpt
 

Recently uploaded (20)

一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
一比一原版(UCSB文凭证书)圣芭芭拉分校毕业证如何办理
 
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
 
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
一比一原版(Coventry毕业证书)考文垂大学毕业证如何办理
 
The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
 
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
在线办理(英国UCA毕业证书)创意艺术大学毕业证在读证明一模一样
 
Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......Palo Alto Cortex XDR presentation .......
Palo Alto Cortex XDR presentation .......
 
Learn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queriesLearn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queries
 
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
4th Modern Marketing Reckoner by MMA Global India & Group M: 60+ experts on W...
 
Everything you wanted to know about LIHTC
Everything you wanted to know about LIHTCEverything you wanted to know about LIHTC
Everything you wanted to know about LIHTC
 
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
Beyond the Basics of A/B Tests: Highly Innovative Experimentation Tactics You...
 
办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样
办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样
办(uts毕业证书)悉尼科技大学毕业证学历证书原版一模一样
 
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging DataPredictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
 
Natural Language Processing (NLP), RAG and its applications .pptx
Natural Language Processing (NLP), RAG and its applications .pptxNatural Language Processing (NLP), RAG and its applications .pptx
Natural Language Processing (NLP), RAG and its applications .pptx
 
一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理
一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理
一比一原版(牛布毕业证书)牛津布鲁克斯大学毕业证如何办理
 
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
一比一原版(Glasgow毕业证书)格拉斯哥大学毕业证如何办理
 
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
 
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
一比一原版(爱大毕业证书)爱丁堡大学毕业证如何办理
 
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
原版制作(swinburne毕业证书)斯威本科技大学毕业证毕业完成信一模一样
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
 
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
 

Programming for Data Analysis: Week 4

  • 1. Programming for Data Analysis Week 4 Dr. Ferdin Joe John Joseph Faculty of Information Technology Thai – Nichi Institute of Technology, Bangkok
  • 2. Today’s lesson Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok 2 • Permutations • Combinations • Laboratory
  • 3. Permutations • A permutation of a set of distinct objects is an ordered arrangement these objects. • An ordered arrangement of r elements of a set is called an r- permutation. • The number of r-permutations of a set with n elements is denoted by P(n,r). A = {1,2,3,4} 2-permutations of A include 1,2; 2,1; 1,3; 2,3; etc…
  • 4. Counting Permutations • Using the product rule we can find P(n,r) = n*(n-1)*(n-2)* …*(n-r+1) = n!/(n-r)! How many 2-permutations are there for the set {1,2,3,4}? P(4,2) 12 !2 !4 1*2 1*2*3*4 3*4 ===
  • 5. Combinations • An r-combination of elements of a set is an unordered selection of r element from the set. (i.e., an r-combination is simply a subset of the set with r elements). Let A={1,2,3,4} 3-combinations of A are {1,2,3}, {1,2,4}, {1,3,4}, {2,3,4}(same as {3,2,4}) • The number of r-combinations of a set with n distinct elements is denoted by C(n,r).
  • 6. Example Let A = {1,2,3} 2-permutations of A are: 1,2 2,1 1,3 3,1 2,3 3,2 6 total.Order is important 2-combinations of A are: {1,2}, {1,3}, {2,3} 3 total. Order is not important If we counted the number of permutations of each 2- combination we could figure out P(3,2)!
  • 7. How to compute C(n,r) • To find P(n,r), we could first find C(n,r), then order each subset of r elements to count the number of different orderings. P(n,r) = C(n,r)P(r,r). • So C(n,r) = P(n,r) / P(r,r) )!(! ! !)!( )!(! )!( ! )!( ! rnr n rrn rrn rr r rn n − = − − = − − =
  • 8. A club has 25 members. • How many ways are there to choose four members of the club to serve on an executive committee? • Order not important • C(25,4) = 25!/21!4! = 25*24*23*22/4*3*2*1 =25*23*22 = 12,650 • How many ways are there to choose a president, vice president, secretary, and treasurer of the club? • Order is important • P(25,4) = 25!/21! = 303,600
  • 9. The English alphabet contains 21 consonants and 5 vowels. How many strings of six lower case letters of the English alphabet contain: • exactly one vowel? • exactly 2 vowels • at least 1 vowel • at least 2 vowels
  • 10. The English alphabet contains 21 consonants and 5 vowels. How many strings of six lower case letters of the English alphabet contain: • exactly one vowel? Note that strings can have repeated letters! We need to choose the position for the vowel C(6,1) = 6!/1!5! This can be done 6 ways. Choose which vowel to use. This can be done in 5 ways. Each of the other 5 positions can contain any of the 21 consonants (not distinct). There are 215 ways to fill the rest of the string. 6*5*215
  • 11. The English alphabet contains 21 consonants and 5 vowels. How many strings of six lower case letters of the English alphabet contain: • exactly 2 vowels? Choose position for the vowels. C(6,2) = 6!/2!4! = 15 Choose the two vowels. 5 choices for each of 2 positions = 52 Each of the other 4 positions can contain any of 21 consonants. 214 15*52*214
  • 12. The English alphabet contains 21 consonants and 5 vowels. How many strings of six lower case letters of the English alphabet contain: • at least 1 vowel Count the number of strings with no vowels and subtract this from the total number of strings. 266 - 216
  • 13. The English alphabet contains 21 consonants and 5 vowels. How many strings of six lower case letters of the English alphabet contain: • at least 2 vowels Compute total number of strings and subtract number of strings with no vowels and the number of strings with exactly 1 vowel. 266 - 216 - 6*5*215
  • 14. Corollary 1: Let n and r be nonnegative integers with r  n. Then C(n,r) = C(n,n-r) Proof: C(n,r) = n!/r!(n-r)! C(n,n-r) = n!/(n-r)!(n-(n-r))! = n!/r!(n-r)!
  • 15. Binomial Coefficient Another notation for C(n,r) is . This number is also called a binomial coefficient. These numbers occur as coefficients in the expansions of powers of binomial expressions such as (a+b)n. n r     
  • 16. Pascal’s Identity Let n and k be positive integers with n  k. Then C(n+1,k) = C(n, k-1) + C(n,k). Proof: ),1( )!1(! )!1( )!1(! )1(! )!1(! )1(! )!)(1(! !)1( )!)(1()!1( ! )!(! ! )!1()!1( ! ),()1,( knC knk n knk nn knk knkn knknk nkn knknkk kn knk n knk n knCknC += −+ + = −+ + = −+ +−+ = −+− +− + −+−− = − + +−− = +−
  • 17. 17 Combinatorics • Count the number of ways to put things together into various combinations. e.g. If a password is 6-8 letters and/or digits, how many passwords can there be? • Two main rules: • Sum rule • Product rule
  • 18. 18 Sum Rule • Let us consider two tasks: • m is the number of ways to do task 1 • n is the number of ways to do task 2 • Tasks are independent of each other, i.e., • Performing task 1 does not accomplish task 2 and vice versa. • Sum rule: the number of ways that “either task 1 or task 2 can be done, but not both”, is m+n. • Generalizes to multiple tasks ...
  • 19. 19 Example • A student can choose a computer project from one of three lists. The three lists contain 23, 15, and 19 possible projects respectively. How many possible projects are there to choose from?
  • 20. 20 Set Theoretic Version • If A is the set of ways to do task 1, and B the set of ways to do task 2, and if A and B are disjoint, then: “the ways to do either task 1 or 2 are AB, and |AB|=|A|+|B|”
  • 21. 21 Product Rule • Let us consider two tasks: • m is the number of ways to do task 1 • n is the number of ways to do task 2 • Tasks are independent of each other, i.e., • Performing task 1does not accomplish task 2 and vice versa. • Product rule: the number of ways that “both tasks 1 and 2 can be done” in mn. • Generalizes to multiple tasks ...
  • 22. 22 Example • The chairs of an auditorium are to be labeled with a letter and a positive integer not to exceed 100. What is the largest number of chairs that can be labeled differently?
  • 23. 23 Set Theoretic Version • If A is the set of ways to do task 1, and B the set of ways to do task 2, and if A and B are disjoint, then: • The ways to do both task 1 and 2 can be represented as AB, and |AB|=|A|·|B|
  • 24. 24 More Examples • How many different bit strings are there of length seven?
  • 25. 25 More Examples • Suppose that either a member of the CS faculty or a student who is a CS major can be on a university committee. How many different choices are there if there are 37 CS faculty and 83 CS majors ?
  • 26. 26 More Examples • How many different license plates are available if each plate contains a sequence of three letters followed by three digits?
  • 27. 27 More Examples • What is the number of different subsets of a finite set S ?
  • 28. 28 Example Using Both Rules • Each user on a computer system has a password, which is six to eight characters long where each character is an uppercase letter or a digit. Each password must contain at least one digit. How many possible passwords are there?
  • 29. 29 IP Address Example (Internet Protocol vers. 4) • Main computer addresses are in one of 3 types: • Class A: address contains a 7-bit “netid” ≠ 17, and a 24-bit “hostid” • Class B: address has a 14-bit netid and a 16-bit hostid. • Class C: address has 21-bit netid and an 8-bit hostid. • Hostids that are all 0s or all 1s are not allowed. • How many valid computer addresses are there?
  • 30. 30 Example Using Both Rules: IP address solution • (# addrs) = (# class A) + (# class B) + (# class C) (by sum rule) • # class A = (# valid netids)·(# valid hostids) (by product rule) • (# valid class A netids) = 27 − 1 = 127. • (# valid class A hostids) = 224 − 2 = 16,777,214. • Continuing in this fashion we find the answer is: 3,737,091,842 (3.7 billion IP addresses)
  • 31. 31 Inclusion-Exclusion Principle (relates to the “sum rule”) • Suppose that km of the ways of doing task 1 also simultaneously accomplishes task 2. (And thus are also ways of doing task 2.) • Then the number of ways to accomplish “Do either task 1 or task 2” is m+n−k. • Set theory: If A and B are not disjoint, then |AB|=|A|+|B|−|AB|.
  • 32. 32 Example • How many strings of length eight either start with a 1 bit or end with the two bit string 00?
  • 33. 33 More Examples • Hypothetical rules for passwords: • Passwords must be 2 characters long. • Each password must be a letter a-z, a digit 0-9, or one of the 10 punctuation characters !@#$%^&*(). • Each password must contain at least 1 digit or punctuation character.
  • 34. 34 Sol. Cont’d • A legal password has a digit or puctuation character in position 1 or position 2. • These cases overlap, so the principle applies. • (# of passwords w. OK symbol in position #1) = (10+10)·(10+10+26) • (# w. OK sym. in pos. #2): also 20·46 • (# w. OK sym both places): 20·20 • Answer: 920+920−400 = 1,440
  • 35. 35 Example • How many ways are there to select a third-prize winner from 100 different people who have entered a contest?
  • 36. 36 More Examples • A terrorist has planted an armed nuclear bomb in your city, and it is your job to disable it by cutting wires to the trigger device. • There are 10 wires to the device. • If you cut exactly the right three wires, in exactly the right order, you will disable the bomb, otherwise it will explode! • If the wires all look the same, what are your chances of survival?
  • 37. 37 More Examples • A terrorist has planted an armed nuclear bomb in your city, and it is your job to disable it by cutting wires to the trigger device. • There are 10 wires to the device. • If you cut exactly the right three wires, in exactly the right order, you will disable the bomb, otherwise it will explode! • If the wires all look the same, what are your chances of survival? P(10,3) = 10·9·8 = 720, so there is a 1 in 720 chance that you’ll survive!
  • 38. 38 More Examples • How many permutations of the letters ABCDEFG contain the string ABC?
  • 39. 39 More Examples • How many ways are there to select a committee to develop a discrete mathematics course if the committee is to consist of 3 faculty members from the Math department and 4 from the CS department, if there are 9 faculty members from Math and 11 from CS?
  • 40. 40 Combinations with Repetition • The number of r-combinations from a set with n elements when repetition of elements is allowed are C(n+r-1,r)
  • 41. 41 Combinations with Repetition Example: How many ways are there to select 5 bills from a cash box containing $1 bills, $2 bills, $5 bills, $10 bills, $20 bills, $50 bills, and $100 bills? Assume that the order in which bills are chosen does not matter and there are at least 5 bills of each type.
  • 42. DSA 207 – Permutation and combination • Create pivot table to find month wise average of internal and external temperature, humidity and carbon monoxide levels in the fish data • Visualize the binning of humidity levels in fish data over a particular time of a day in a month. Do it with the following • 1. Qcut • 2. Cut • 3. Naming Bins • Solve two combinatorics problem Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok 42