You are on page 1of 14

THE UNIVERSITY OF THE WEST INDIES

ASSIGNMENT 1
SEMESTER I, 2012/2013
Code and Name of Course: COMP2101 Discrete Mathematics



Assignment 1 - Individual Assignment

AREA

DESCRIPTION
Objectives To have a student apply the knowledge garnered during the first few weeks of
the course

Title Assignment 1 Individual Assignment

Deliverable The answers for the questions which follow the given case

Instructions 1. Review Lectures of the first three weeks of the course, the COMP2101
Text and any other related Discrete Mathematics material
2. Read the Assignment 1 Sheet thoroughly
3. Submit the gradable solution by using the
COMP2101 Assignment 1 - Individual located within the
ASSIGNMENTS Section of the OURVLE COMP2101/CS20S Course
Environment. This may also be accessed by choosing the Assignments
section below Activities

Format The solution for this assignment must be submitted as a Microsoft Word
document.

Your ID number should form part of the Microsoft Word file name. The file
name should take the format COMP2101 Assignment 1 Semester 1 2012-
2013 XXXXXXXX where XXXXXXXX represents the student ID number.

Upload
Constraint
Assignment should be uploaded in the relevant space provided in
OURVLE (See Instructions section above). A message indicating File
uploaded successfully will acknowledge that the f ile has been sent
successfully.

Do NOT assume your project has been received if you do not get this
acknowledgement.

Scoring Rubric Your electronic submission will be evaluated on:
1. Your attempt of the compulsory questions 1, 3 and 6
2. The response submitted for each question (See detail individual
marks below) Maximum 50 marks

The actual grade of 50 marks will be displayed. The actual grade allocated is
the percentage of the maximum marks (5 points)

Late
Assignments
Late assignments are accepted. These are however graded then 25%
deducted for each day of late submission.

Expectation It is expected that students will discuss means to a solution. The actual work
written is expected to reflect each students uniqueness. Where replication of
work is identified, each paper will be graded. The allocated grade to each
students piece of work for where this anomaly is identified will be the grade
divided by the number of replications discovered.


Due Date

Sunday, September 30, 2012


Question 1 [10 marks] COMPULSORY
[The fraction of the marks attained for this question determines the fraction of the
attained marks to be allocated for question 2.]
Where the number of repetitions of each object is known as in the word MISSISSIPPI
and all objects will be in the selection, Given a sequence with n objects where there are
n
1
indistinguishable objects of type 1, n
2
indistinguishable objects of type 2, ..., n
t

indistinguishable objects of type t the formula for the number of permutations (orderings)
of is

(a) Where a limitless number of repetitions are allowed, derive a simple formula
for r-permutations (an ordering of r elements) of n objects [2]
(b) By using the derived formula in (a), state a formula for r
1
-permutations of n
1

objects and r
2
-permutations of n
2
objects and ... and r
i
-permutations of n
i

objects [2]
(c) Using your formula in (b), state a simplified formula for the number of unique
passwords, assuming a password such as 6539FF#$! is made up of 4 digits, 2
letters of the English alphabet, and 3 special characters. For ease of reference,
it is accepted that there are 32 special characters. [1]
(d) Describe the considerations and/or assumptions for deriving the formulae in
(a), (b) and (c). [5]

Question 2 [5 marks]
(a) A computer access password consists of from one to five letters chosen from
the 26 in the alphabet with repetitions allowed. How many different
passwords are possible? [2]
(b) If any seven digits could be used to form a telephone number, how many
seven-digit telephone numbers would have at least one repeated digit? [3]
! !...n !n n
n!
t 2 1
Question 3 [12 marks] COMPULSORY
[The fraction of the marks attained for this question determines the fraction of the
attained marks to be allocated for questions 4 and 5.]
(a) Using your own words, state the third form of the Pigeonhole Principle [3]
(b) Describe the type of questions that may be solved using the third form of the
Pigeonhole Principle [1]
(c) Develop a question that the third form of the Pigeonhole Principle may be
used to solve. [3]
(d) Using the third form of the Pigeonhole Principle, solve the question in (c). [5]

Question 4 [5 marks]
Solve the following question using Tree Diagrams.
A four-person committee composed of Adam, Belv, Core and Davi is to select a
chairperson, secretary, and treasurer. How many selections are there in which
either Adam is treasurer or Davi is chairperson? [5]

Question 5 [6 marks]
Using any programming language taught in your first year at the university, write a
function fib_check that takes a list of integers, l and returns True if they are
consecutive numbers within the Fibonacci sequence. False is returned otherwise. [6]

Question 6 [3 marks] COMPULSORY
[The fraction of the marks attained for this question determines the fraction of the
attained marks to be allocated for questions 7, 8 and 9.]
In your own words, describe why some recurrent relations equations cannot be solved
using Master Theorem. [3]

Question 7 [3 marks]
Expand the following expression using the binomial theorem:
(5u
2
3v)
4
[3]

Question 8 [2 marks]
By drawing Pascals Triangle, determine the row of Pascals triangle containing the
following binomial coefficients 9 0 ,
9
s s
|
|
.
|

\
|
k
k


Question 9 [4 marks + Bonus 5 marks]
[On Final Page]

Question 9 [4 marks + Bonus 5 marks]
Let f(n) be defined by
4
5
2
16 ) (
3 ) 1 (
n
n
f n f
f
+
|
.
|

\
|
=
=

if n > 1 and n = 2
m
, where m is a positive integer.

(a) By using the principles of Recurrence Relation, find a general formula
for f(n) [4]

(b) Hence show that f(n) = (n
4
lg n). [Bonus - 5]

Question 1 [10 marks] COMPULSORY
[The fraction of the marks attained for this question determines the fraction of the
attained marks to be allocated for question 2.]
Where the number of repetitions of each object is known as in the word MISSISSIPPI
and all objects will be in the selection, Given a sequence with n objects where there are
n
1
indistinguishable objects of type 1, n
2
indistinguishable objects of type 2, ..., n
t

indistinguishable objects of type t the formula for the number of permutations (orderings)
of is

(a) Where a limitless number of repetitions are allowed, derive a simple formula
for r-permutations (an ordering of r elements) of n objects [2]
(b) By using the derived formula in (a), state a formula for r
1
-permutations of n
1

objects and r
2
-permutations of n
2
objects and ... and r
i
-permutations of n
i

objects [2]
(c) Using your formula in (b), state a simplified formula for the number of unique
passwords, assuming a password such as 6539FF#$! is made up of 4 digits, 2
letters of the English alphabet, and 3 special characters. For ease of reference,
it is accepted that there are 32 special characters. [1]
(d) Describe the considerations and/or assumptions for deriving the formulae in
(a), (b) and (c). [5]
Solution 1 [10 marks] COMPULSORY
[This question must be done for marks to be allocated for question 2. ]
[ ]
[Marks are as per sub-questions. ]

(a) n
r

(b) n
1
r
1
n
2
r
2
. . . n
i
r
i
or
[
=
i
k
r
k
k
n
1

(c) 10
4
26
2
32
3


(d) Considerations and/or assumptions for n
r

i. r is a positive integer, i.e. r Z
+

Considerations and/or assumptions for n
1
r
1
n
2
r
2
. . . n
i
r
i

i. r and i are positive integers, i.e. r, i Z
+

Considerations and/or assumptions for 10
4
26
2
32
3

i. All 10 digits may occupy any or all of positions 1 to 4 of the password
ii. There are 26 letters in the English alphabet
iii. The password is made up of the 4 digits, 2 letters and 3 special characters,
in the same order
! !...n !n n
n!
t 2 1
iv. As the question states that the formula derived in (b) should be used, we
accept that ordering is important and repetitions are allowed.


Question 2 [5 marks]
(a) A computer access password consists of from one to five letters chosen from
the 26 in the alphabet with repetitions allowed. How many different
passwords are possible? [2]
(b) If any seven digits could be used to form a telephone number, how many
seven-digit telephone numbers would have at least one repeated digit? [3]
Solution 2 [5 marks]
[Marks are as per sub-questions. ]

(a) Passwords consisting of from 1 to 5 letters from the alphabet
= Passwords of 1 letter + Passwords of 2 letters
+ Passwords of 3 letters + Passwords of 4 letters
+ Passwords of 5 letters
= 26
1
+ 26
2
+ 26
3
+ 26
4
+ 26
5


= 26 + 676 + 17576 + 456976 + 11881376

= 12356630

(b) 7-digit telephone numbers with at least one repeated digit
= All 7-digit numbers less 7-digit numbers with no repeated digits
= 10
7
-
10
P
7
= 10,000,000 604800
= 9,395,200


Question 3 [12 marks] COMPULSORY
[The fraction of the marks attained for this question determines the fraction of the
attained marks to be allocated for questions 4 and 5.]
(a) Using your own words, state the third form of the Pigeonhole Principle [3]
(b) Describe the type of questions that may be solved using the third form of the
Pigeonhole Principle [1]
(c) Develop a question that the third form of the Pigeonhole Principle may be
used to solve. [3]
(d) Using the third form of the Pigeonhole Principle, solve the question in (c). [5]
Solution 3 [12 marks] COMPULSORY
[This question must be done for marks to be allocated for questions 4 and 5. ]
[ ]
[Marks are as per sub-questions. ]

(a) The third form of the Pigeonhole Principle states that given two sets X and Y
where the number of elements in X, |X| may or may not exceed the number of
elements in Y, |Y|, we may consider our elements of X as pigeons flying to occupy
the available elements of Y, the pigeonholes.

We find that if the number of elements in each set were equal, i.e. |X| = |Y|, each
element in X (or each pigeon) would have its unique mapping (or its unique
pigeonhole so that each pigeonhole contains exactly one pigeon). More
specifically, some (at least one) pigeonhole will contain at least |X|/|Y| pigeons.
Likewise, if the number of elements in set X were twice that in set Y,
i.e. |X| = 2|Y|, a minimum of two elements in X (or each pair of pigeon) would
have a mapping (or share a pigeonhole so that each pigeonhole could contain
exactly two pigeons). More specifically, some (at least one) pigeonhole will
contain at least |X|/|Y| pigeons. As |X|=2|Y|, then some (at least one) pigeonhole
contains 2 pigeons. But the number of elements in X may not be exactly divisible
by that in Y, therefore the division could be a decimal. We must round up to
provide for the existence of an element of X that need to map unevenly
somewhere in Y (or a pigeonhole that may not have the even number of pigeons as
the other pigeonholes), thereby giving rise for a rounding up or a ceiling in the
computation |X|/|Y|.

The general case which accounts for integer or decimal divisions is as follows:
If the number of elements in set X were n and that in set Y were m,

a minimum of the rounded up figure or ceiling of |X|/|Y|=n/m elements in X
(or pigeons) would have the same mapping in Y (or share a pigeonhole).

(b) The type of questions that may be solved using the third form of the Pigeonhole
Principle are questions where one type of objects is to occupy or map to another
type of objects, maybe boxes. More specifically, where the first and second form
of the Pigeonhole Principle tend to identify where some pigeonhole(s), element(s)
in a set, or box(es) could have at least two objects occupying or mapping same, the
third form could be used to compute to any finite positive integer.

(c) Question: Each school year, the number of weekly tutorial sessions to be offered
varies with the number of students doing a certain course. In 2012/2013, each
studying pursuing COMP2101 is required to register for any one of four tutorial
sessions. If there are 73 students pursuing COMP2101 in the year stated, show
that some tutorial session may have no less than 19 students.

(d) Let the COMP2101 students be the set X, such that |X| = n = 73.
The COMP2101 tutorial sessions be the set Y, such that |Y| = m = 4
By the Pigeonhole Principle
if n objects are to be placed in m boxes,

then some box(es) contain |X|/|Y|=n/m elements
Therefore
if 73 COMP2101 students are to be placed in 4 tutorial sessions

then some tutorial sessions contain 73/4=18.25 = 19 students
It is true that some tutorial session may have no less than 19 students.


Question 4 [5 marks]
Solve the following question using Tree Diagrams.
A four-person committee composed of Adam, Belv, Core and Davi is to select a
chairperson, secretary, and treasurer. How many selections are there in which
either Adam is treasurer or Davi is chairperson? [5]
Solution 4 [5 marks]
[Correct Labelling of Tree showing Chairperson, Secretary, Treasurer - 1 mark ]
[Correct Chairperson Row with appropriate nodes - 1 mark]
[Correct Secretary Row with appropriate nodes - 1 mark]
[Correct Treasurer Rows with appropriate nodes - 1 mark]

Let A Adam, B Belv, C Core, and D Davi
Root


Chairperson B C D


Secretary C D B D B C A


Treasurer A A A A A C A B C B

From the Tree Diagram, the number of selections in which either Adam is treasurer or
Davi is chairperson is TEN (10).


Question 5 [6 marks]
Using any programming language taught in your first year at the university, write a
function fib_check that takes a list of integers, l and returns True if they are
consecutive numbers within the Fibonacci sequence. False is returned otherwise. [6]
Solution 5 [6 marks]
[Function demonstrates correct understanding of Fibonacci sequence - 2 marks ]
[Correct steps of implementation based on programming language - 3 marks ]
[Correct solution - 1 mark ]

##Sample Python Recursive Solution
def fib_check(l):
if len(l) == 0:
return False
elif len(l) == 1:
return (l[0] == 1 or l[0] == 0)
elif len(l) == 2:
return (l[1] == 1) and fib_check(l[:len(l)-1])
else:
return (l[len(l)-2]+l[len(l)-3]==l[len(l)-1]) and fib_check(l[:len(l)-1])

##Sample Python Iterative Solution
def fib_check(l):
if len(l) == 0:
return False
else:
for i in range(len(l)-1):
if i == 0 and l[i] != 1 and l[i] != 0:
return False
elif i == 1 and l[i] != 1:
return False
elif i > 1 and (l[len(l)-2]+l[len(l)-3]!=l[len(l)-1]):
return False
return True

##Sample Java Solution
public boolean fib_check (List l) {
int prev1=0, prev2=0;

if (l == null)
return false;
else {
for (int i = 1; l != null; i++) {
if (i == 1 && l.value != 1 && l.value != 0)
return false;
else if (i == 2 && l.value != 1)
return false;
else if (prev1+prev2 != l.value)
return false;
prev1 = prev2;
prev2 = l.value;
l = l.next;
}
return true;
}
}

##Sample Scheme Recursive Solution
(define (fib_check l)
(define (fib_values l prev1 prev2)
(if (null? l)
#t
(and (= (+ prev1 prev2) (car l)) (fib_values (cdr l) prev2 (car l)))
)
)
(cond ((null? l) #f)
((and (not (= (car l) 1)) (not (= (car l) 0))) #f)
((and (null? (cdr l)) (or (= (car l) 1) (= (car l) 0))) #t)
((and (not (null? (cdr l))) (not (= (cadr l) 1))) #f)
((and (and (not (null? (cdr l))) (= (cadr l) 1)) (null? (caddr l))) #t)
(else (fib_values (cddr l) (car l) (cadr l)))
)
)


Question 6 [3 marks] COMPULSORY
[The fraction of the marks attained for this question determines the fraction of the
attained marks to be allocated for questions 7, 8 and 9.]
In your own words, describe why some recurrent relations equations cannot be solved
using Master Theorem. [3]
Solution 6 [3 marks] COMPULSORY
[This question must be done for marks to be allocated for questions 7, 8 and 9. ]
[ ]
[The specificity of Equations to be solved by Master Theorem - 2 marks]
[Any other reasonable reasoning in response - 1 mark ]

If one were to consider solving a problem T with size n inputs as a recurrent relation
T(n) via a Recursion Tree, it is reasonable to assume that the problem may be solved with
a subproblems, each of size n/b. Assuming that this breakdown of the problem results
in additional or overhead work of f(n). This scenario would suggest a recurrent relation
T(n) = aT(n/b) + f(n)
where the recurrent relation contains an internal node aT(n/b) and a leaf f(n). As the
problem is further broken down there would be a number of internal nodes and leaves.
Solving the problem would include a summation of the overheads or leaves over the
entire tree.

Master Theorem assists with easily providing a solution for some recurrent relation
equations, specifically those which match specific cases with relations between the
overhead and a polynomial of the inputs n. Some recurrent relation equations cannot be
solved by Master Theorem because they do not meet the basic conditions that must be in
place for usage of Master Theorem. If the recurrent relation does not follow the format
T(n) = aT(n/b) + f(n)
then Master Theorem cannot be used. Conditions directly implied from the previous
equation that will hinder a Master Theorem solution are:
a < 0 i.e. the number of subproblems is negative
b < 1 i.e. size of the problem increases as the problem is brokendown
negative f(n) i.e. the overhead of solving the problem is decreased by breakdown.

Even where the recurrent relation is of the previous equation, due to the specificity of
Master Theorem, there are further conditions that will hinder a Master Theorem solution.
The conditions which includes the overhead f(n) are:
i. The relation between the overhead f(n) and n
logba
is not a polynomial
ii. For an arbitrary > 0, where f(n) = O(n
logba
), we find that f(n) O(n
logba-
)
iii. If - another function g(n) contained in f(n) and f(n) = (n
logba
g(n)) and
a. g(n) log
k
n, or
b. g(n) = log
k
n but k<0
iv. For an arbitrary > 0, where f(n) = (n
logba
), we find that
a. f(n) (n
log+
)
b. f(n) = (n
log+
) but af(n/b) > cf(n) for a constant c<1
and at least one large n.


Question 7 [3 marks]
Expand the following expression using the binomial theorem:
(5u
2
3v)
4
[3]
Solution 7 [3 marks]
[Appropriate Formula - marks ]
[Correct expansion and substitution of formula - 1 marks ]
[Correct calculations towards result - 1 mark ]

By Binomial Theorem


Required (5u
2
3v)
4

Let a = 5u
2
, b = -3v, n = 4


= C(4,0)a
4
b
0
+ C(4,1)a
4-1
b
1
+ C(4,2)a
4-2
b
2
+ C(4,3)a
4-3
b
3
+ C(4,4)a
4-4
b
4

= 1a
4
b
0
+ 4a
3
b
1
+ 6a
2
b
2
+ 4a
1
b
3
+ 1a
0
b
4

By Substitution
= 1(5u
2
)
4
(-3v)
0
+ 4(5u
2
)
3
(-3v)
1
+ 6(5u
2
)
2
(-3v)
2
+ 4(5u
2
)
1
(-3v)
3
+ 1(5u
2
)
0
(-3v)
4

= 1(625u
8
) + 4(-375u
6
v) + 6(75u
4
v
2
) + 4(-135u
2
v
3
) + 1(81v
4
)

= 625u
8
1500u
6
v + 450u
4
v
2
540u
2
v
3
+ 81v
4

= +
n
k
k k n n
b a k n C b a
0
) , ( ) (

=
4
0
4 2 4 2
) 3 ( ) 5 )( , 4 ( ) 3 5 (
k
k k
v u k C v u

Question 8 [2 marks]
By drawing Pascals Triangle, determine the row of Pascals triangle containing the
following binomial coefficients 9 0 ,
9
s s
|
|
.
|

\
|
k
k

Solution 8 [2 marks]
[Any Attempt (Right or Wrong) - mark ]
[Correct Rows 1-3 - mark]
[Correct Rows 4-6 - mark]
[Correct Rows 7-9 - mark]
1
1 1
1 2 1
1 3 3 3
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
1 7 21 35 35 21 7 1
1 8 28 56 70 56 28 8 1
1 9 36 84 126 126 84 36 9 1

Therefore, the row of Pascals triangle containing the binomial coefficients 9 0 ,
9
s s
|
|
.
|

\
|
k
k
is
1 9 36 84 126 126 84 36 9 1


Question 9 [4 marks + Bonus 5 marks]
Let f(n) be defined by
4
5
2
16 ) (
3 ) 1 (
n
n
f n f
f
+
|
.
|

\
|
=
=

if n > 1 and n = 2
m
, where m is a positive integer.

(a) By using the principles of Recurrence Relation, find a general formula
for f(n) [4]

(b) Hence show that f(n) = (n
4
lg n). [Bonus - 5]

Solution 9 [4 marks + Bonus 5 marks]
[Individual steps towards general equation - 2 marks ]
[Finding general equation f(n) = 16
m
f(n/2
m
) + m x 5n
4
- 2 marks ]
[Making substitutions and finding f(n) = 3 x n
4
+ 5n
4
x log
2
n - 2 marks ]
[Proving Big-Oh - 1 marks ]
[Proving Omega - 1 mark ]
[Proving Theta - mark ]

f(n) = 16 f(n/2) + 5n
4
.....1

= 16 [ 16 f(n/4 ) + 5(n/2)
4
] + 5n
4

= 16
2
f(n/4 ) + 16 x 5n
4
/2
4
+ 5n
4

= 16
2
f(n/4 ) + 2x5n
4
.....2

= 16
2
[ 16 f(n/8 ) + 5(n/4)
4
] + 2x5n
4

= 16
3
f(n/8 ) + 16
2
x 5n
4
/4
4
+ 2x5n
4

= 16
3
f(n/8 ) + 3x5n
4
.....3

= 16
3
[ 16 f(n/16 ) + 5(n/8)
4
] + 3x5n
4

= 16
4
f(n/16 ) + 16
3
x 5n
4
/8
4
+ 3x5n
4

= 16
4
f(n/16 ) + 4x5n
4
.....4

= ......

= 16
m
f(n/2
m
) + m x 5n
4


As n = 2
m

n/2
m
= 1 AND log
2
n = m
As m = log
2
n AND n/2
m
= 1
f(n) = 16
log
2
n
f(1) + log
2
n x 5n
4

= (2x2x2x2)
log
2
n
f(1) + 5n
4
x log
2
n

= (2
log
2
n
x2
log
2
n
x2
log
2
n
x2
log
2
n)
f(1) + 5n
4
x log
2
n

= n x n x n x n f(1) + 5n
4
x log
2
n

= n
4
f(1) + 5n
4
x log
2
n


As f(1) = 3


So
f(n) = 3n
4
+ 5n
4
log
2
n



As n = 2
m
where m is a positive integer,
log
2
n m

f(n) 3n
4
x log
2
n + 5n
4
x log
2
n


8n
4
log
2
n

Recall that lg n means log
2
n
Therefore
f(n) = O (n
4
log
2
n

)

f(n) = O (n
4
lg n

)

Likewise
f(n) = 3 x n
4
+ 5n
4
x log
2
n


5n
4
x log
2
n


Therefore
f(n) = (n
4
x log
2
n

)

f(n) = (n
4
lg n

) i.e. Omega (n
4
x log
2
n

)

Having proven f(n) = O (n
4
lg n

) and f(n) = (n
4
lg n

)
f(n) = (n
4
lg n

) i.e. Theta (n
4
lg n

)

You might also like