National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
5.4 Generating Functions with Two or More Variables
137
receive a multiple of five gumdrops. How many ways are there to distribute the
gumdrops such that at least one childs restriction is satisfied?
Exercise 5.3.19 A distinct partition of n is a way of w
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
98
4 Distribution Problems
Proposition 4.2.1 The number of ways to distribute n balls to k unlabeled urns in
such a way that no urn receives more than one ball is given by:
(i) 0 if n > k;
(ii) 1 otherwise.
Proof If n > k, then at least one urn will recei
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
4.4 The Twelvefold Way
113
4.4 The Twelvefold Way
The problem of distributing balls into urns seems innocent. However, it actually provides a framework for a more general, abstract problem. This framework is described
as the Twelvefold Way. The Twelvefold
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
100
4 Distribution Problems
Example 4.2.8
(i) Find the number of distributions of n1 unlabeled red balls and n2 unlabeled
white balls into k labeled urns.
(ii) Find the number of distributions of n1 unlabeled red balls and n2 unlabeled
white balls into k
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
120
5 Generating Functions
Substituting in x = 1 and x = 2 yields:
x = 2 2 = A1,1 and
x = 1 2 = A2,2 /2 A2,2 = 4.
To solve for A2,1 , we can substitute a third value in for x (say x = 0). This yields
2 = 2 + A2,1 4. Hence A2,1 = 4.
Alternately, we can com
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
94
3 The Binomial Coefficient
So, by the Addition Principle, the total number of configurations is given by
13
!
k=0
Ak  =
13 "
!
k=0
"
#
#
26!
26!
2
(26!(26! 1)(26! 2)(26 ) 13
2k (26 2k)!k!
2 13!
3 10114 .
One of the key steps in the cryptanalysis of
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
106
4 Distribution Problems
Similarly, suppose cfw_1 , ., k is a partition of n into k parts. This corresponds
to placing i unlabeled balls into the ith urn. Since the i > 0, no urn will be left
empty.
!
It would be desirable to find a concise formula fo
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
4.2 The Solution of Certain Distribution Problems
97
A variation on the above example would be to consider the case where we are are
offering the children gumdrops before dinner. Again, the gumdrops can be considered
unlabeled balls and the children can b
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
4.2 The Solution of Certain Distribution Problems
101
Since the Ai are disjoint sets, it follows that the number of distributions is given
by
#"
#
k " #"
!
k n2 1 n 1 + i 1
Ai  =
.
i
i1
k1
i=1
i=1
k
!
!
Note that in the previous example, the roles of th
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
5.1 Review of Factoring and Partial Fractions
119
Choosing two distinct values of x will yield a system of two equations with two
unknowns, which we can then solve. We make the convenient choices of x = 1 and
x = 2.
x = 1 3 = 3A1 A1 = 1
x = 2 5 = 6A2 A2 =
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
102
4 Distribution Problems
However, some distributions may be in both A and B. Note that A B is the set of
all distributions in which every urn receives at least one ball. In this case, we can
simply ignore the colors. Hence, this is a distribution of n
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
5.3 Single Variable Generating Functions
135
Finally, we determine A B. Using a similar argument as above, this is given
by the coefficient of x 20 in
!
"
$
#2
1
x + x 3 + x 5 + x 7 + x 11 + x 13 + x 17 + x 19 .
3
1x
Using a computer algebra system, we
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
92
3 The Binomial Coefficient
Fig. 3.4 The Enigma
machine
The internal workings of the Enigma consisted of three rotors (see Fig. 3.5), each
of which would perform a different substitution cipher. Each day, the German military
would specify which rotors w
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
124
5 Generating Functions
We can also consider the multiplication of two series.
!
!
n
n
Theorem 5.2.4 Let f (x) =
n=0 fn x and g(x) =
n=0 gn x . It follows that
# n
$
"
"
f (x)g(x) =
fk gnk x n .
n=0
k=0
Proof Note that
f (x)g(x) = (f0 + f1 x + + fk x
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
5.4 Generating Functions with Two or More Variables
139
f (x, y) = 3x 11 y 23 + 3x 11 y 22 + x 10 y 23 + 2x 11 y 21
+3x 10 y 22 + x 9 y 23 + 3x 11 y 20 + 2x 10 y 21 + 2x 8 y 23 + 2x 11 y 19 + x 10 y 20 + 3x 9 y 21 + x 8 y 22
+x 11 y 18 + 2x 10 y 19 + 2x 9
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
116
5 Generating Functions
We now present two theorems regarding the roots of polynomials. The proofs of
these theorems are omitted, but can be found in any algebra text.
Theorem 5.1.2 Let f (x) be a polynomial and let c C. c is a root of f (x) if and
onl
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
126
5 Generating Functions
From this, it is possible to extract the nth derivative of the composition function.
This extraction is left as an exercise to the reader.
We end this section with a list of other common power series. The derivation of
these ser
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
4.3 Partition Numbers and Stirling Numbers of the Second Kind
111
Hence, the Addition Principle yields
k2
n " #
!
!
n
S(i, k1 )
Ai  =
S(n i,j ) .
A =
i
i=1
i=1
j =1
n
!
By reversing the roles of the red and white urns yields the cardinality of B, nam
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
5.2 Review of Power Series
125
f2 = 2g0 g2 + g12 g2 =
=
f2 g12
2g0
f2
f2
g2
f2
1 = 13/2 .
2g0
2g0
2 f0
4f0
Recall that one of our initial problems was to find the nth derivative of a composition function. By manipulating the power series for the function
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
90
3 The Binomial Coefficient
to disguise their messages. So, much of the security of the message is dependent
on a message key. A message key is the specific method used within the system to
disguise the message. So for instance, the specific k used with
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
104
4 Distribution Problems
Exercise 4.2.18 Find the number of distributions of n1 labeled red balls and n2
unlabeled white balls into k labeled urns if each urn must receive at least one white
ball. What if each urn must receive both a red and a white ba
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
114
4 Distribution Problems
elements of K to be indistinguishable. This being the case, we are only concerned with which elements of N are grouped together. This corresponds to
distributions of n labeled balls into k unlabeled urns.
(iv) Functions in whic
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
130
5 Generating Functions
The beauty of the Taylor polynomial is that we can evaluate it at a particular value of
x, say x = 1. The effect of this is that it sums up all the coefficients of the powers of
x up to x 50 . Equivalently, this gives the number
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
4.3 Partition Numbers and Stirling Numbers of the Second Kind
109
Table 4.6 Summary of results for n balls into k urns
Unlabeled balls
Unlabeled urns
Unlabeled balls
Labeled urns
Labeled balls
Unlabeled urns
Labeled balls
Labeled urns
No restriction
!k
i=
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
Programming Language
Homework 4
5/15 ()
1. Consider the following program written in C syntax
void swap(int a, int b)
cfw_
int temp;
temp = a;
a = b;
b = temp;
Void main()
cfw_
int value = 2, list[5] = cfw_1, 3, 5, 7, 9;
swap(value, list[0]);
swap(list
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
Fireflies in the Garden
410311220
1. While watching this film, what impressed you very much? What is it
about? Why did it impress you very much?
When Mike's mother died because of a car accident, Mike recorded the time
at 11:11. And then he will watch t
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
1052
The Crow and the Snake
Please translate following sentences into Chinese. (70%)
So I mean to use my wits to save our race from entire destruction! (p. 73)
The kings son came along to bathe in the river. (p. 74)
Mrs. Crow popped it, with all has
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
Backtracking
Difficult Problems
Many require you to find either a subset or
permutation that satisfies some constraints and
(possibly also) optimizes some objective function.
May be solved by organizing the solution space
into a tree and systematically
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
BranchShengLung
and Bound
Peng
Problem (Solution, State) Space
General problem statement
Given a problem instance P,
find answer A=(a1, a2, , an) such that
the criteria C(A, P) is satisfied.
Problem space of P is the set of all possible
answers A.
2
E
National University of Computer and Emerging Sciences, Lahore
Introduction To Cloud Computing
COMPUTER S cs2345

Spring 2016
Chapter 10 Implementing Subprograms
The General Semantics of Calls and Returns
The subprogram call and return operations of a language are together called its
subprogram linkage.
A subprogram call in a typical language has numerous actions associated with