You are on page 1of 3

Capital University of Science and Technology

Department of Computer Science


CS2053– Discrete Structures
Final Term Exam (BS CS)
Semester: Spring 2021 Max Marks: 80
Date: July 15, 2021 Time: 180 Min
Instructors: Asifa Kanwal
Instructions:
 There are FOUR questions on TWO pages. Attempt all questions.
 This exam carries 40% weight towards course evaluation.

Name: Reg. No.

PART I

Question No.1. (CLO–1) (4x5=20)

Answer the following questions

I What is the value of the variable x after the statement


if 2 + 2 = 4 then x := x + 1 (initially x=0)

II What are the contrapositive, the converse, and the inverse of the conditional statement?
“The home team wins whenever it is raining?”

III Show that (p ∧ q) → (p ∨ q) is a tautology.

IV Find the product of (100 0111)2, (111 0111)2

V Determine whether each of these sets is finite, countably infinite, or uncountable.


i The set A × Z+ where A = {2, 3}
ii The real numbers between 0 and 2

PART II

Question No. 2. (CLO – 2) (10+10=20)

I A parking lot has 35 visitor spaces, numbered from 0 to 34.Visitors are assigned parking
spaces using the hashing function h(k) = k mod m, where k is the number formed from
the first 4 digits on a visitor’s license plate and m is the total number of spaces.

SE2053 Discrete Structures Page 1 of 3


a Which spaces are assigned by the hashing function to cars that have these first
three digits on their license plates: 3171, 4108, 1007, 1020, 1811, 5310?

b Describe a procedure visitors should follow to find a free parking space, when the
space they are assigned is occupied.

II Encrypt the message using blocks of five letters and the transposition cipher based on the
permutation of {1, 2, 3, 4, 5} with σ(1) = 3, σ(2) = 5, σ(3) = 1, σ(4) = 2, and σ(5) = 4. For
this exercise, use the letter S as many times as necessary to fill out the final block of
fewer than five letters. The message should be your registration number along with your
complete name.

PART III

Question No. 3. (CLO – 2) (5+7+3+5=20)

I Compute the time complexity of the given algorithm

Max-Subsequence-Sum(Array, N)//Where N is size of Array


{
int this-sum = 0, Max-sum = 0;
for(int i = 0; i < N; i++)
{ for(int j = i; j < N; j++)
{
this-sum = 0;
for(int k = i; k <= j; k++)
this-sum = this-sum + Array[k];
if(this-sum > Max-sum)
Max-sum = this-sum;
}
}
return(Max-sum);
}

II How many divisions are required to find gcd (13566, 35742) using the Euclidean
algorithm?
III Which positive integers less than 18 are relatively prime to 18?

IV Write all mathematical step to calculate the 8964 mod 38.

SE2053 Discrete Structures Page 2 of 3


PART IV

Question No. 4. (CLO – 3) (7+5+8=20)

V Use mathematical induction to show that all n ≥ 1, the sum of the squares of the first 2n
positive integers is given by the formula

n(2 n+1)(4 n+1)


1+ 2 + 22 + 32 + · · · + (2n)2 = whenever n is a positive integer.
3

VI Find f (2), f (3), f (4), and f (5) if f is defined recursively by f (0) = -1 and f (1) = 2 and
for

n = 1,2,3,….

(a): f (n + 1) = 3f (n)2 − 4f (n − 1)2.

(b): f (n + 1) = f (n)2f (n − 1)

VII Consider a recursive function is defined such as


f(a − 1,f(a,b − 1)) , if a ≥ 1 and b ≥ 2
0 , if a ≥ 1 and b = 0
b , if a=1
3 , if a ≥ 1 and b = 1
Find the values of the following functions
(I) f(1, 0) (ii) f(0, 1) (iii) f(1, 1) iv) f(2, 2)

SE2053 Discrete Structures Page 3 of 3

You might also like