HW2-CSCI-190

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 34

Thar Linn Htet

CSCI 190 | CRN-40643

Homework 2

Chapter 5

Section 5.1
No.4

(a) 13 = [1. (1+1)/2]2

(b) P (1) shown in part a equal to 1.

(c) Inductive hypothesis:

13 +23 +···+k3 = ( k (k + 1)/2)2

(d) For inductive steps, I need to show for each k>=1 that P(k) implies P(k+1).

[13 +23 +···+k3] + (k+1)3 =( (k + 1)(k + 2)/2)2

(e) (k(k+1)/2)2 + (k+1)3 = (k+1)2(k2/4+k+1) = (k+1)2((k2+4k+4)/4) = ((k+1)(k+2)/2)2

No.6

1 · 1! + 2 · 2! + · · · + k · k! + (k + 1) · (k + 1)! = (k + 1)! − 1 + (k + 1) · (k + 1)!

= (k + 1)! (1 + k + 1)-1= (k + 2)! -1

Section 5.2
No.2
Let P(n) be the given statements.
From the given definition, it is clear that P(1), P(2), and P(3) is true.
Now assume the statement is true for n=k.
Then show that P(k+1) is true.
Since k≥3, k−2 is a positive integer less than or equal to k, so by the inductive
hypothesis, it is clear that P(k−2) is true.
It can infer from the hypothesis that P(k−2) is true.
By the definition, it is clear that "three farther down in arrangement also falls"
Therefore, P(k−2+3) = P(k+1) also falls.

No.4

(a)

We know that 18 = (4×1) + (7×2)

So, P (18): 18 cents can be formed using two 7-cent stamps and one 4-cent stamp.

19 = (4×3) + (7×1)

So, P (19): 19 cents can be formed using three 4-cent stamps and one 7-cent
stamp.

20 = (4×5) + (7×0)

So, P (20): 20 cents can be formed using five 4-cent stamps.

21 = (4×0) + (7×3)

So, P (21): 21 cents can be formed using three 7-cent stamps.

Therefore, the basis step is complete, and P(n) is true for 18,19,20,21.

(b)

Inductive hypothesis:

The inductive hypothesis of the proof is that P(n) is true for all n≥18 This means
that we assume that for any postage amount n between 18andk (inclusive), we can
form that postage using just 4−cent stamps and 7−cent stamps.

(c)

In the inductive step, we need to prove that if P(k) is true, then P(k+1) is also true.
In other words, we need to show that if we can form a postage of k cents using 4-
cent stamps and 7-cent stamps, then we can also form a postage of k+1 cents
using just 4-cent stamps and 7-cent stamps.

(d)

For k ≥ 21, assume that P(j) is true for all integers j such that 18 ≤ j ≤ k. We need to
show that P(k+1) is also true.
Since P(k−2) is true by the inductive hypothesis, we can form (k−2) + 7=k+5 cents
using only 4-cent and 7-cent stamps. Therefore, we can form k+1 cents using
(k+5−7) = k−2 cents of 4-cent stamps and one 7-cent stamp. Thus, P(k+1) is true.
It completes the inductive step for k ≥ 1.

(e)

By the principle of strong induction, we have shown that P(n) is true for all integers
n ≥ 18, since we have shown that P(k) is true for all integers k such that 18≤ k ≤
21, and we have shown that if P(k) is true for all integers k such that 18 ≤ k <n,
then P(n) is also true. Therefore, we have shown that P(n) is true for all integers n ≥
18.

Section 5.3
No.2

f (0) = 3

(a)

f(n+1) = -2f(n)
put n = 0,
f (0+1) = -2 f (0)
f (1) = -6

put n = 1,
f (1+1) =-2 f (1)
f (2) = 12

put n = 2
f (1+2) = -2 f (2)
f (3) = -24

f (4) = -2 f (3) = 48
f (5) = -2 f (4) = -96

(b)

f(n+1) = 3f(n) + 7
put n = 0,
f (0+1) = 3f (0) + 7
f (1) = 16

f(n+1) = 3f(n) + 7
put n = 1,
f (1+1) = 3f (1) + 7
f (2) = 55

f(n+1) = 3f(n) + 7
put n = 2,
f (2+1) = 3f (2) + 7
f (3) = 172

f (4) = 3f (3) + 7 =523


f (5) = 3f (4) + 7 = 1576

(c)
f(n+1) = f(n)2 -2f(n)-2
f (0 + 1) = f (0)2- 2 f (0)-2
f (1) = 9-6-2= 1
f (2) = 1-2-2= -3
f (3) = 9+6-2 = 13
f (4) = 169-26-2 = 141
f (5) = 19881-282-2= 19597
(d)
f(n+1) = 3f(n)/3
f (0+1) = 3f(0)/3
f (1) = 3
f (2) = 3
f (3) = 3
f (4) = 3
f (5) = 3

No.4

(a)
n=1,
f (2) = f (1) – f (0) =1−1=0

n=2
f (3) = f (2) – f (1) = 0−1=−1

n=3
f (4) = f (3) – f (2) =−1−0=−1

n=4
f (5) = f (4) – f (3) = −1+1=0

(b)
n=1,
f (2) = f (1) * f (0) =1
n=2
f (3) = f (2) * f (1) = 1

n=3
f (4) = f (3) * f (2) =1

n=4
f (5) = f (4) * f (3) = 1

(c)
n=1,
f (2) = (f (1) )2 + (f (0))3 =1+ 1= 2

n=2
f (3) = (f (2) )2 + (f (1))3 = 4+ 1= 5

n=3
f (4) = (f (3) )2 + (f (2))3 = 25+ 8= 32

n=4
f (5) = (f (4) )2 + (f (3))3 =1089+ 125= 1214

(d)

n=1

f (2) = f (1) / f (0) = 1

n=2

f (3) = f (2) / f (1) = 1

n=3

f (4) = f (3) / f (2) = 1

n=4

f (5) = f (4) / f (3) = 1

No.8

(a)

an = 4n-2

n=1, a1= 4-2=2


n=2, a2= 8-2=6 =2+4 = a1 + 4

n=3, a3= 12-2=10 =6+4 = a2 + 4

n=n, an= an-1+ 4

an = 4n-2

a0 = 0-2 = -2

(b)

an = n(n+1)

n=1, a1= 1(1+1) = 2

n=2, a2= 2(2+1) = 6 =2+4 = an-1 + 2x2

n=3, a3= 3(3+1) =12 =6+6 = an-1 + 2x3

n=n, an= an-1+ 2n

an = n(n+1)

a0 = 0

(c)

an = 1+ (-1)n

n=1, a1= (1-1) = 0

n=2, a2= 1+1 = 2

n=3, a3= 1-1 =0= a1

n=4, a4= 1+1 =2= a2

n=n, an= an-2+0

(d)

an = n2

n=1, a1= 1
n=2, a2= 4= 1+2.2-1 = a1+ 2.2-1

n=3, a3= 9 =0=4+2.3-1= a2+2.3-1

n=4, a4= 16 =9 + 2.4-1= a3+2.4-1

n=n, an= an-1+2n-1

a0= 0

Section 5.4
No.2

i=1:

result =1×1=1

i = 2:

result =1×2=2

i = 3:

result = 2 * 3 = 6

i = 4:

result = 6 * 4 = 24

i = 5:

result = 24 * 5 = 120

i = 6:

result = 120 * 6 = 720

6! = 720

No.8

Algorithm sum (n: positive integer) returns an integer


if n = 1

return 1

else

return n + sum (n - 1)

1. If n=1, the algorithm returns 1, which is the sum of the first positive
integer.
2. If n>1, the algorithm calculates n + sum (n−1). This recursive call
essentially adds the current positive integer n to the sum of the first
n−1 positive integers, which is achieved by calling the sum function
with n−1.
o sum(1)=1 (base case)
o sum(2)=2+sum(1)=2+1=3
o sum(3)=3+sum(2)=3+3=6
o sum(4)=4+sum(3)=4+6=10

The algorithm recursively adds the positive integer n to the sum of the first n−1
positive integers until it reaches the base case (n=1), at which point it returns 1.

This algorithm uses the formula n(n+1)/2 indirectly through the recursive calls, as it
computes the sum incrementally by adding each positive integer from 1 to n.

Chapter 6

Section 6.1
No.2

Number of floors =27

Number of offices on each floor =37

Total number of offices in the building =Number of floors× Number of offices on each
floor

Total number of offices =27×37

Total number of offices =999

There are 999 offices in the building.


No.8

The first letter can be chosen from any of the 26 letters, so we have 26 choices.

The second letter can be chosen from the remaining 25 letters (since we don't want
any repetition), so we have 25 choices.

The third letter can be chosen from the remaining 24 letters, giving us 24 choices.

To find the total number of initials, we multiply these choices together:

26x25x24 = 15600
Therefore, there are 15,600 different three-letter initials that people can have,
assuming none of the letters are repeated

No.30

The total number of English letters are 26 and the total number of digits are 10.

For license plates that can be made using three uppercase English letters followed by
three digits.

There are 26 choices for each of the three uppercase English letters and 10 choices
for each of the three digits.

26.26.26.10.10.10 = 17,576,000

For license plates that can be made using four uppercase English letters followed by
two digits.

There are 26 choices for each of the four uppercase English letters and 10 choices
for each of the two digits.

26.26.26.26.10.10 = 45,697,600

The total number of license plates are:

17,576,000 + 45,697,600 = 63,273,600

No.40

The objective is to find the number of subsets of a set with 100 elements that have
more than one element.

Let A be a set with 100 elements.


Use the result, the number of subsets of a set with n elements has 2n subsets.

Then the number of subsets of A is 2100.

The subsets of A having less than or equal to one element is and 100 subsets
having single element.

That is, 101 elements.

Therefore, the number of subset of A having more than one element is: 2100- 101.

No.44

The number of ways of seating a group of 4 people from the 10 people.

= 10.9.8.7

=5040

Since, individuals can rotate the persons around the table in 4 ways and get the
same seating arrangement.

The required number of ways = 5040/4 = 1260

Section 6.2
No.2

There are 30 students in the class.

The objective is to show that at least two have last names that begin with the same
letter.

The number of alphabets is 26.

Suppose the beginning letter of the last name of every student is different from the
others.

Then, there can be at most 26 students in the class whose beginning letter of the
last name is different.

Use the Pigeonhole Principle. If N objects are placed into k boxes, then there is at
least one box containing ⌈N/k⌉ objects.

The number of objects is 30, and the number of boxes (Alphabets) is 26.
Substitute N = 30 and k=26

⌈N/k⌉= ⌈30/26⌉= ⌈1.15⌉= 2 (Using ceiling function definition)

This value ⌈N/k⌉ = 2 means that, there is at least one alphabet as a beginning letter
of the last name of at least two students.

Therefore, at least two students have last names that begin with the same letter.

No.4

Consider a bowl containing 10 red balls and 10 blue balls. A selection of a ball is
made by a woman at random.

(a)

A woman wants at least three balls of the same color. Objective is to determine the
minimum number of balls to be selected so that there is a surety of having at least
three balls of the same color.

This problem will be done with the help of the Generalized Pigeonhole
principle which states that:

If N objects are placed into k boxes, then there is at least one box containing at
least ⌈N/k⌉ objects.

Let us suppose that pigeonholes are the colors, which are two in numbers (red and
blue). We need to define the objects N such that ⌈N/k⌉ = 3 or ⌈N/2⌉ = 3

Since our interest is in the minimum number of balls so the least positive integer to
satisfy the equation is 5 because 5/2 = 2.5 and ⌈5/2⌉ = 3 (a ceiling function).

Hence, 5 balls must be select to be sure of having at least three balls of the same
color.

(b)

Objective is to determine the minimum number of balls to be selected so that there


is a surety of having at least three blue balls.

Suppose that when woman selects a ball it comes out to be red. This process may
happen up to 10 times, that is, the first 10 choices may all be red balls. Since there
are only 10 red balls, so the eleventh ball must be blue ball.

Thus, the woman needs to choose at least 13 balls to be sure that at least 3 of
them are blue.
No.8

f: S → T is a function such that |S| > |T|

Suppose |T| = n and so |S| >= n+1

So, n+1 or more elements are mapped on to n elements using pigeon-hole principle.
There is at least one pair of elements mapped onto the same image. In other
words f(r) = f(t) for some distinct S, T in S. So, f is not a one-to-one function.

No.18

There are 9 students in a discrete mathematics class in a college.

(a)

Arrange the male students and female students as pigeon holes as follows: (0,9),
(1,8), (2,7), (3,6), (4,5), (5,4), (6,3), (7,2), (8,1), (9,0) in the order (M, F).

The students of the college must match any one of the above pair.

Observe that in each pair if the number of male is less than 5 then the number of
female is more than five, and vice versa.

Thus, we say that number of either male or female must be at least five.

(b)

Also, observe that in each pair if there are no three females then there are at least
7 males (the last three ordered pairs of the 10 in (a)).

Similarly, if there are no three males then there are at least 7 females (the first
three ordered pairs of the ten in (a)).

Therefore, in this case there are at least three male students or seven female
students.

Section 6.3
No.4
Consider the set S = {1,2,3,4,5}

(a)
Its need to list all the 3-permutations of S = {1,2,3,4,5}

For permutations, order matters. The number of r- permutations from a set


of n elements is

P (n, r) =n! / (n-r)!

In this case, n = 5 and r = 3. So, P (5,3) = 5! / (5-3)! = 5! / 2! = 5x4x3 = 60

Therefore, number of 3-permutations of S = {1,2,3,4,5} are 60

Distinct 3-permutations of S = {1,2,3,4,5} are

(b)

Its need to list all the 3-combinations of S = {1,2,3,4,5}

For combinations, order doesn’t matter. The number of r- combinations from a set
of n elements is C (n, r) =n! / r! (n-r)!

In this case, n= 5 and r = 3. So, C (5,3) = 5! / 3!(5-3)! = 5! / 3!2! = 10

Therefore, number of 3-combinations of S = {1,2,3,4,5} are 10 and they are

123,124,125,134,135,145,234,245,345.

No.6
(a) C (5,1) = 5/ (5-1)!1! = 5! / 4! = 5x 4! / 4! = 5

(b) C (5,3) = C (5,2) = 5x 4 / 1x 2 = 10

(c) C (8,4) = (8x7x6x5) / (1x2x3x4) = 70

(d) C (8,8) = 8! / (8-8)!.8! = 8! / 0!.8! =1

(e) C (8,0) = ⌊8 / ⌊8-0. ⌊0 = 8! /8! (1) = 1

(f) C (12, 6) = 12! / (12-6) ! . 6! = (6! X7x8x9x10x11x12) / 6! x 6! = 924

No.10

The objective is to find the different orders can the names of the candidates be
printed on a ballot for governor.

Six different candidates to be printed on six different ballots and the arrangement is
an ordered arrangement. So, it is a permutation.

Use the formula of r - permutations of a set with n distinct elements.

The number of ways the names of the candidates is printed on a ballot is:

P (6,6) = 6! / (6-6)! = 6! / 0! = (6x5x4x3x2x1) / 1 = 720

Therefore, there are 720 number of ways the names of the candidates be printed on
a ballot for governor.

No.12

(a)

The number of bit strings of length 12 that contain exactly 3 ones

= C (12,3) = 220

But permuting 1s does not give a new arrangement.

(b)

At most three ones are present in a bit string of length 12. So, the number of bit
strings are

= C (12,3) + C (12, 2) + C (12,1) + C (12,0)


= 220 + 66 + 12 + 1

=299

(c)

At least three ones are present in a bit string of length 12. So, the number of bit
strings is

= C (12,3) + C (12,4) + C (12,5) + C (12,6) + C (12,7) + C (12,8) + C (12,9) + C


(12,10) + C (12,11) + C (12,12)

= 2 {C (12,3) + C (12,4) + C (12,5)} + C (12,2) + C (12,1) + C (12,0) + C (12,6)

= 2{220+ 495 + 792} + 924 + 66 + 12 + 1

=4017.

(d)

The number of bit strings of length 12 that contains equal number of zeroes and
ones

= C (12,6)

= 924

Section 6.4
No.2

(a)

Using combinatorial reasoning

(x + y)5 = (x + y) (x + y) (x + y) (x + y) (x + y)

= (xx + xy + yx + yy) (xxx + xxy + xyx + yxx + xyy + yxy + yyx + yyy)

= (x2 + 2xy + y2) (x3 + 3x2y + 3xy2 + y3)

= x5 + 5x4y + 10x3y2 + 10x2y3 + 5xy4 + y5

(b)
= x5+ 5x4y + 10x3y2 + 10x2y3 + 5xy4 + y5

No.6

The objective is to find the coefficient of x7 in (1+x)11

Use Binomial

Theorem

to find the coefficient.

The coefficient of x7 is
Therefore, the coefficient of x7 is 330.

No.8

Consider the function (3x+2y)17

The objective is what is the coefficient of x8 y9 in the expansion of (3x+2y)17

The binomial theorem states as,

Let x and y be variables, and let n be a non-negative integer then

In the given problem x = 3x, y = 2y and n = 17.

Thus, the expansion of the given function is

Now substitute j = 9 in the above expansion then we get the coefficient of x8 y9.

The coefficient of x8 y9 in the expansion (3x + 2y)17 is


So, the coefficient of x8 y9 in the expansion of (3x + 2y)17 is

No.12

Consider the row of Pascal’s triangle containing the binomial

coefficients is shown below:

1 10 45 120 210 252 210 120 45 10 1

Objective is to use Pascal’s identity to produce the row following immediately the
above row.

Pascal’s identity:

Suppose two positive integers n and k with n>=k then the pascal’s identity:

Substitute n = 10, and k = 1 in the above identity.

11 = 1 + 10

Hence, pascal’s identity is verified.

Use the binomial coefficients to find the immediately following row of the given
row in Pascal’s triangle.
Substitute n = 10, and k = 0 in

Substitute n = 10, and k = 1 in

Substitute n = 10, and k = 2 in

Substitute n = 10, and k = 3 in

Substitute n = 10, and k = 4 in


Substitute n = 10, and k = 5 in

Substitute n = 10, and k = 6 in

Substitute n = 10, and k = 7 in

Substitute n = 10, and k = 8 in

Substitute n = 10, and k = 9 in


Substitute n = 10, and k = 10 in

Substitute n = 10, and k = 11 in

Hence, the required row is shown below:

1 11 55 165 330 462 462 330 165 55 11 1

Chapter 7
Section 7.1

No.2

The total number of possible outcomes:6

Number of successful outcomes (a die comes up 6):1

Probability that a die comes up six when it is rolled once is,

P (6) = No. favorable outcomes/ No. possible outcomes

= 1/6

No.8

The objective is to find the probability that a five-card poker hand contains the ace of
hearts.

The sample space S is the set of all 5-card poker hands.

The number of ways to choose 5 cards from 52 cards is C (52, 5).

So, |S| = C (52,5).


The event E is the subset of S in which each element contains the ace of hearts.

To calculate |E| note that once a hand contains the ace of hearts, these remain C
(51, 4) ways to complete that hand.

Choose four more cards from 51 remaining cards.

So, |E| = C (51,4).

Use the formula to find the probability that a five card poker hand contains
the ace of hearts.

Therefore, the probability that a five cards poker hand contains the ace of hearts is
5/52.

No.30

The objective is to find the probability that a player of a lottery wins the prize offered
for correctly choosing five numbers out of six integers.

Let S be the set of all selection of 6 numbers from 1 to 40.

So, the total number of selections is |S| = C (40,6).

Let E be the event of choosing correctly five numbers out of six integers.

So, the number of possibilities for 5 correct and 1 incorrect number is:

|E| = C (6,5) x C (40-6,1)


As there can be only one set of 5 integers for which the prize is offered and the
remaining one integer must be selected from the any of the remaining 35 integers.

The probability that a player wins the prize offered is P(E).

Therefore, the probability that a player of a lottery wins the prize offered for correctly
choosing five numbers out of six integers is 5.31 x 10-5

Section 7.2
No.2

When a loaded die is rolled, the probability of getting a 3 is twice the probability of
getting the other five numbers.

Let p be the probability of getting the each of the other five numbers.

This implies that the probability of 3 is 2p because; the probability of getting a 3 is


twice the probability of getting the other five numbers.

Here, when a loaded die is rolled, the possible outcomes are 1, 2, 3, 4, 5, and 6.

The probability of getting each of the numbers 1, 2, 4, 5, and 6 is p, and the


probability of getting 3 is 2p.

P(1) + P(2) + P(3) + P(4) + P(5) + P(6) = 1

p+ p+ 2 p+ p+ p+ p = 1

7p=1

P = 1/7
Therefore, the probability of each of the numbers 1, 2, 4, 5, and 6 is 1/7 and the
probability of 3 is 2/7.

No.6

S = {1,2,3}

Then E = {123,132,213}

→ |E| = 3

The total number of permutations of the elements of set ‘S’ is 3! = 6 (3! = P(3,3))

The probability that 1 precedes 3 is P (E) = 3/6 = 1/2

(b) Let ‘S’ represent the set of all permutations of {1,2,3}.

→ |S| = 3! = 6

Let ‘E’ be the event that 3 precedes 1.

Then E = {(3,1,2), (3,2,1), (2,3,1)}.

→ |E| = 3

The probability that 3 precedes 1 is

= 3/6 = 1/2

(c) Let ‘S’ represent the set of all permutations of {1,2,3}.

→ |S| = 3! = 6 (Note: 3! = P (3,3))

Let ‘E’ represent the event that 3 precedes both 1 and 2.

Then E = {(3,1,2) (3,2,1)}

|E| = 2

The probability that 3 precedes both 1 and 2 is = 2/6 = 1/3


No.12

Assume that E and F are events.

Consider that P(E) = 0.8 and P(F) = 0.6

The objective is to show that P(EF)  0.8 and P(EF)  0.4

Here P(EF) is the probability of occurrence of either E or F.

P(EF)  P (E)

P(EF)  0.8 Since P(E) = 0.8

Hence, the probability of occurrence of either E or F should be,

P(EF)  0.8

Recollect the addition theorem of probability:

P(EF) = P (E) + P (F) - P(EF)

Probability value lies between 0 and 1.

P(EF)  1

P (E) + P (F) - P(EF)  1 By addition theorem of probability

Substitute the values of P(E) = 0.8 and P(F) = 0.6 in the above formula.

P (E) + P (F) - P(EF)  1

0.8 + 0.6 - P(EF)  1

1.4 – 1  P(EF)

0.4  P(EF)

Hence, the probability of occurrence of both E and F should be,

P(EF)  0.4

No.24
The objective is to find the conditional probability that exactly four heads appear
when a fair coin is flipped five times, when the first flip came up tails.

Let E be the event that exactly four heads appear when flipping a fair coin 5 times
and F be the event that the first flip is a tail.

There are 25= 32 equally possible outcomes when flipping a coin 5 times.

The only way to get 4 heads when the first flip is tails is THHHH, so P(EF) = 1/32.

The probability of the first of 5 coin flips coming up tails is ½. So, P(F) = ½.

Substitute them in

P(E/F) = (1/32)/(1/2) = (1/32) x 2 = 1/16

Therefore, the conditional probability that exactly four heads appear when a fair coin
is flipped five times, when the first flip came up tails is 1/16.

No.26

Consider E be the event that a randomly generated bit string of length three contains
an odd number of 1s.

A bit has a single binary value, either 0 or 1.

Here, totally 4 bit strings of length three that contains an odd number of 1s:

100,010,001, and 111.

So, the event E becomes, E = {100, 010, 001,111}.

And, |E| = 4.

Consider F be the event that the string starts with ‘1’.

Here, totally 4 bit strings of length three that starts with 1: 100, 110, 101, and 111.

So, the event F becomes, F = {100, 110, 101, 111}.

And, |F| = 4.
EF = {100, 010, 001, 111} {100,110, 101, 111}

= {100, 111}

|E  F | = 2

In general, the sample space S of an experiment is the set of all possible outcomes.

In this experiment, the set of all possible outcomes are 8. They are, {000, 010, 001,
100, 110, 011, 101, 111}

So, |S| = 8

Recollect, definition of probability,

Suppose E is an event that is a subset of a sample space S, then, the probability of


an event E is defined as,

Where, |E| is the number of outcomes in E, and, |S| is the total number of
outcomes.

Recollect, the definition of Independent Sets,

Suppose E, and, F are two events, then, the events E, and, F are independent if and
only if

P (E  F) = P (E) x P(F)
Therefore, the two events E and F are independent events.

Chapter 8

Section 8.1
No.8

(a)

The objective is to find a recurrence relation for the number of bit strings of
length that contain three consecutive 0’s .

First case:

The bit string ends in 1. In this case, the bit string having length n-1 has an-1 possible
strings that has a pair of consecutive 0’s.

Second case:

The bit string ends in 10. In this case, the bit string having length n-2 has an-
2 possible strings that has a pair of consecutive 0’s.

Third case:

The bit string ends in 100. In this case, the bit string having length n-3 has an-
3 possible strings that has a pair of consecutive 0’s

Fourth case:
The bit string ends in 000. There are 2n-3bit strings of length n-3 and so there are 2n-
3bit strings of length n-3 followed by 00.

Add all the number of sequences to get the required relation: an = an-1 + an-2 + an-3 +
2n-3

(b)

If n=0, there are 0bit strings with three consecutive 0’s.

This implies ao = 0

If n=1, there are 0bit strings with three consecutive 0’s.

This implies a1 = 0

If n=2, there are 0bit strings with three consecutive 0’s.

This implies a2 = 0

If n=3, there is 1bit strings with three consecutive 0’s.

Use the recurrence relation to get that a3 = a2 + a1 + a0 + 23-3 = 1

The relation is satisfied for n=3

This implies that n=3 is not an initial condition.

Thus, the initial condition is a0 = a1 + a2 = 0.

(c)

Use the recurrence relation obtain in part (a),

an = an-1 + an-2 + an-3 + 2n-3

The initial condition obtained in part (b),

a0 = a 1 + a 2 = 0

a2 = 1

a3 = a2 + a1 + a0 + 23-3
=0+0+0+1=1

a4 = a3 + a2 + a1 + 24-3

=1+0+0+2=3

a5 = a4 + a3 + a2 + 25-3

= 3+ 1 + 0 + 4 = 8

A6 = a5 + a4 + a3 + 26-3

= 8 + 3 + 1 + 8 = 20

a7 = a 6 + a 5 + a 4 + 2 5

= 20 + 8 + 3 + 16 = 47

The 47 bits strings of length seven contain three consecutive 0’s.

Section 8.3
No.8

(a)

f (1) = 5 and f (n) = 2f (n/2) + 3, if n is even number,

f (2) = 2 f (1) + 3

=2 (5) + 3

= 13

(b)

f (4) = 2 f (2) + 3

=2 (13) + 3

= 29

f (8) = 2 f (4) + 3

=2 (29) + 3
= 61

(c)

f (16) = 2 f (8) + 3

=2 (61) + 3

= 125

f (32) = 2 f (16) + 3

=2 (125) + 3

= 253

f (64) = 2 f (32) + 3

=2 (253) + 3

= 509

(d)

f (1024) = 2f (512) + 3

= 2(2f (256) +3) +3

= 2(2(2f (128) + 3) + 3) +3

= 2(2(2(2f (64) + 3) + 3) +3) + 3

Now substitute the value of f (64) in above equation,

f (1024) = 2(2(2(2f (64) + 3) + 3) +3) + 3

= 2(2(2(2(509) + 3) + 3) +3) + 3

=8189

Therefore, the value of f (1024) is 8189.

No.10

f(n) = f(n/2) + 1 Also, f (1) = 1


Again, apply the recurrence relation with n =2k-1, to get

Again, apply the recurrence relation with n =2k-2, to get

Substitute f (1) =1, to get

f(2k) = k+1

Hence, the value of f(n) when n = 2k is k+1

No.14

The number of teams in the tournament is of the form n = 2k

Apply divide and conquer algorithm as below:

For k = 1 the number of teams in the tournament is n = 2. Therefore, there is only


one round in the tournament.

Thus, k= 1, n = 2 and f (2) = 1

For k =2, the number of teams in the tournament is n =22. Therefore, there will be
two rounds in the tournament. In the first round there will be two matches between
two pairs of teams and in the second round there will be one match between the
winners of the first round.

Thus, k= 1, n = 4 and f (22) = 2

For k = 3, the number of teams in the tournament is n = 23. Therefore, there will be
three rounds in the tournament. In the first round there will be three matches
between three pairs of teams and in the second round there will be two matches
between the winners of the first round. And in the third round there will be one match
between the winners of second round.

Thus, k= 1, n = 4 and f (23) = 3

f (21) = 1

f (22) = 2

= f (21) + 1

f (23) = 3

=2 + 1

= f (22) + 1

Thus, f (22) = f (22-1) + 1 and f (23) = f (23-1) + 1

Therefore, this can be generalized as f (2k) = f (2k-1) + 1

Hence, the recurrence formula for the number of rounds in the tournament is

f(n) = f(n/2) + 1 where n = 2k

No.16

The objective is to solve the recurrence relation for the number of rounds in the
tournament.

Let f(n) be the number of rounds with n teams.

Every time the function increments by 1, the total number of teams is halved.

That is n→ n/2.

So, the function can be written as f(n) = f(n/2) + 1 and f(1) = 0.

As n= 2k substitute n value in f(n) repeatedly as:


f (n) = f (2k)

= f (2k / 2) + 1

=f (2k-2) + 1 since f(n) = f(n/2) + 1

Again, apply the function definition to get:

f(n) = [ f (2k-2 / 2) + 1] + 1

= f (2k-2 / 2) + 2

Continue this process until it reaches 20

f(n) = [ f (2k-2 / 2) + 1] + 2

= f(2k-3) + 3

= f (22) + (k-2)

= [f (22 / 2) + 1] + (k-2)

= f (21) + (k-1)

= [ f (21 / 2) + 1] + (k-1)

= f (20) + k

= f (1) + k

Substitute the initial condition f (1) = 0 in f(n).

f(n) = 0 + k

=k

= log2n. since n = 2k → k = log2n

Therefore, the number of rounds in the tournament is k or log2n.

You might also like