Sample Jrfcs 2022ch2 Cs2
Sample Jrfcs 2022ch2 Cs2
The CS2 question paper has TWO parts: PART A (20 marks)
and PART B (40 marks).
Note that all questions in the sample set are not at the same level
of difficulty, and may not carry equal marks in an examination.
PART A
1
3. Consider the pseudo-code given below.
Input: Integers b and c.
1. a0 ← max(b, c), a1 ← min(b, c).
2. i ← 1.
3. Divide ai−1 by ai . Let qi be the quotient and ri be the remainder.
4. If ri = 0, then go to Step 8.
5. ai+1 ← ai−1 − qi ∗ ai .
6. i ← i + 1.
7. Go to Step 3.
8. Print ai .
What is the output of the above algorithm when b = 28 and c = 20?
What is the mathematical relation between the output ai and the two
inputs b and c?
*
*****
H rows *********
*************
*****************
*************
*********
*****
*
2
Precisely what will happen to the array A if the following piece of
code is executed? Justify your answer with an example enumerating
different steps.
for i := 1 to n − 1
while A[i] ̸= i do
Reverse(A, i, A[i]).
3
10. Given an array A = {a1 , a2 , . . . , an } of unsorted distinct integers, write
a program in pseudo-code for the following problem: given an integer
u, arrange the elements of the array A such that all the elements in
A which are less than or equal to u are at the beginning of the array,
and the elements which are greater than u are at the end of the array.
You may use at most 5 extra variables apart from the array A.
15. A set S contains integers 1 and 2. S also contains all integers of the
form 3x+y where x and y are distinct elements of S, and every element
of S other than 1 and 2 can be obtained as above. What is S? Justify
your answer.
16. Show that if S is any subset of {1, 2, . . . , 2n} such that |S| > n, then
S contains two numbers such that one of them divides the other.
4
17. Prove that every natural number n ≥ 1 has a multiple whose decimal
representation contains only 1s and 0s. (Hint: Consider the numbers
1, 11, 111, 1111, . . . and their remainders modulo n).
18. How many k-element subsets of {1, 2, . . . , n} exist that contain no two
consecutive numbers?
20. Let N denote the set of natural numbers. For each of the following
sets, state whether it is finite or infinite. Justify your answers.
(a) {f : N → {0, 1} | ∀n ∈ N, f (n) ≤ f (n + 1)}
(b) {f : N → {0, 1} | ∀n ∈ N, f (2n) ̸= f (2n + 1)}
(c) {f : N → {0, 1} | ∀n ∈ N, f (n) ̸= f (n + 1)}
21. Find the number of distinct positive integers that can be formed using
0, 1, 2 and 4, where each of these integers is used at most once.
22. Derive an expression for the maximum number of regions that can be
formed within a circle by drawing n chords.
23. Given A = {1, 2, 3, . . . , 70}, show that for any six elements a1 , a2 , a3 ,
a4 , a5 and a6 belonging to A, there exists one pair ai and aj for which
|ai − aj | ≤ 14 (i ̸= j).
24. Calculate how many integers in the set {1, 2, 3, . . . , 1000} are not di-
visible by 2, 5, or 11.
5
25. Consider all the permutations of the digits 1, 2, . . . , 9. Find the number
of permutations each of which satisfies all of the following:
• the sum of the digits lying between 1 and 2 (including 1 and 2)
is 12,
• the sum of the digits lying between 2 and 3 (including 2 and 3)
is 23,
• the sum of the digits lying between 3 and 4 (including 3 and 4)
is 34, and
• the sum of the digits lying between 4 and 5 (including 4 and 5)
is 45.
27. There are n students in a class. The students have formed k commit-
tees. Each committee consists of more than half of the students. Show
that there is at least one student who is a member of more than half
of the committees.
28. Consider an m × n integer grid. A path from the lower left corner at
(0, 0) to the grid point (m, n) can use three kinds of steps, namely (i)
(p, q) → (p + 1, q) (horizontal), (ii) (p, q) → (p, q + 1) (vertical), or (iii)
(p, q) → (p + 1, q + 1) (diagonal). Derive an expression in terms of m
and n for Dm,n , the number of such distinct paths.
29. The numbers 1, 2, . . . , 10 are circularly arranged. Show that there are
always three adjacent numbers whose sum is at least 17, irrespective
of the arrangement.
30. Consider six distinct points in a plane. Let m and M denote respec-
tively the minimum and the √ maximum distance between any pair of
points. Show that M/m ≥ 3.
6
31. A group of 15 boys plucked a total of 100 apples. Prove that two of
those boys plucked the same number of apples.
P
33. Find the value of ij, where the summation is over all integers i and
j such that 1 ≤ i < j ≤ 10.
35. How many triplets of real numbers (x, y, z) are simultaneous solutions
of the equations x + y = 2 and xy − z 2 = 1?
7
PART B
I. Computer Science
C2. Suppose a lockdown has been announced at your place. You plan to
spend the very first day of the lockdown by watching movies on a TV
with no recording facility. You have received a schedule of movies to
appear on all the channels on the said day. You do not like to switch
over from one movie to another, and your aim is to watch as many
complete movies as possible. Suppose there are n distinct movies for
which the corresponding start and end times are available across all
the channels. Write an efficient program (using pseudo-code) to find
the maximum number of complete movies that you can watch on the
day. Analyze the time complexity of your algorithm.
C3. Consider a hard disk whose storage space S is divided into a number
of logical sectors (segments) of equal length l. A batch of requests
for storing data into it is served in such a way that no piece of data
is fragmented to accommodate the same over more than one sectors
under the assumption that the length of each piece of data is less than
the sector size and a single sector can accommodate multiple pieces of
data.
Write an algorithm to store a given set of m successive storage requests
{s1 , s2 , ..., sm } using the minimum number of sectors, where si is the
8
size
P of i-th data request, si < l, for each i and
i s i < S. For example, consider the set of data storage requests
{2kb, 5kb, 4kb, 7kb, 1kb, 3kb, 8kb} into a hard disk of sector length
10kb. The minimum number of sectors required for the storage is 3
and a possible distribution of the data pieces into 3 sectors are {2kb,
8kb}, {4kb, 1kb, 5kb} and {7kb, 3kb}.
C4. Consider the task of multiplying two integer matrices A and B, each
of size 500 × 500. Each matrix can have at most 500 non-zero entries.
Any row of A or B that contains at least one non-zero element, must
have no less than 50 non-zero elements.
(a) Propose a space-efficient data structure for this task.
(b) Based on your proposed data structure, design an efficient algo-
rithm to multiply A and B. The resulting matrix should be stored
separately.
(c) What is the maximum number of integer multiplications needed
to complete this task as per your implementation?
9
(c) Using your data structure from (a), design an efficient algorithm
to find a set R ⊆ S that is special (as defined in (b)). You will
get full credit only if your algorithm takes O(n) time in the worst
case.
C7. There are n students standing in a line. The students have to rearrange
themselves in ascending order of their roll numbers. This rearrange-
ment must be accomplished only by successive swapping of adjacent
students.
(a) Design an algorithm for this purpose that minimises the number
of swaps required.
(b) Derive an expression for the number of swaps needed by your
algorithm in the worst case.
10
C10. Let A be an n × n matrix of integers whose element in the i-th row
and j-th column is denoted by aij . Further, we shall denote by µi the
maximum value that appears in the i-th row, i.e. µ(i) = max{aij : j ∈
{1, 2, . . . , n}}. Suppose that for any i, j such that i < j, if aik = µ(i)
and ajl = µ(j), then k ≤ l (as illustrated in the 5 × 5 matrix below).
3 4 2 1 1
7 8 5 6 4
2 3 6 6 5
5 6 9 10 7
4 5 5 6 8
(a) Write an algorithm for finding the maximum element in each row
of the matrix with time complexity O(n log n).
(b) Establish its correctness, and justify the time complexity of the
proposed algorithm.
L1 L1
L2 L2
L3 L3
(a) (b)
In Figure 1(a), there does not exist any triplet (k, `, m) such that a
straight line can pass through p1k , p2ℓ and p3m . In Figure 1(b), the
triplet (3, 3, 4) is a solution since a straight line passes through p13 , p23
and p34 .
Present an efficient algorithm for solving this problem. Justify its
correctness and worst case time complexity. It can be assumed that
the x, y-coordinates of the points are given as input.
[Full credit will be given if your algorithm is correct, and of worst case time
complexity O(n2 ).]
11
C12. A least expensive connection route among n houses needs to be de-
signed for a cable-TV network. Consider the following algorithm A
for finding a spanning tree.
Algorithm A
Input: G = (V, E)
Output: Set of edges M ⊆ E
Sort E in decreasing order of cost of edges;
i ← 0;
while i < |E| do
begin
Let temp = (u1 , u2 ) be the i-th edge E[i] in E;
Delete E[i], i.e., replace E[i] by φ;
if u1 is disconnected from u2 then
restore temp in list E as E[i];
i ← i + 1;
end
return the edges in E which are not φ;
(a) Prove that the algorithm A can be used to correctly find a least
cost connection route, given a set of n houses and information
about the cost of connecting any pair of houses.
(b) What is the worst case time complexity of A?
(c) If all the edges have distinct cost, how many solutions can there
be?
C13. You are given k sorted lists, each containing m integers in ascending
order. Assume that (i) the lists are stored as singly-linked lists with
one integer in each node, and (ii) the head pointers of these lists are
stored in an array.
(a) Write an efficient algorithm that merges these k sorted lists into
a single sorted list using Θ(k) additional storage.
(b) Next, write an efficient algorithm that merges these k sorted lists
into a single sorted list using Θ(1) additional storage.
(c) Analyse the time complexity of your algorithm for each of the
above two cases.
12
C14. Let A and B be two arrays, each containing n distinct integers. Each
of them is sorted in increasing order. Let C = A ∪ B. Design an
algorithm for computing the median of C as efficiently as you can.
C15. Let B be a rooted binary tree of n nodes. Two nodes of B are said
to be a sibling pair if they are the children of the same parent. For
example, given the binary tree in Figure 2 below, the sibling pairs are
(2, 3) and (6, 7). Design an O(n) time algorithm that prints all the
sibling pairs of B.
2 3
4 5
6 7
C16. Let H1 and H2 be two complete binary trees that are heaps as well.
Assume H1 and H2 are max-heaps, each of size n. Design and analyze
an efficient algorithm to merge H1 and H2 to a new max-heap H of
size 2n.
C17. Let G = (V, E) be an undirected weighted graph with all edge weights
being positive. Design an efficient algorithm to find the maximum
spanning tree of G.
C18. The diameter of a tree T = (V, E) is given by max {δ(u, v)}, where
u,v∈V
δ(u, v) is the shortest path distance (i.e., the length of the shortest
path) between vertices u and v. So, the diameter is the largest of all
shortest path distances in the tree.
(a) Write pseudo-code for an efficient algorithm to compute the di-
ameter of a given tree T .
(b) Analyze the time complexity of your algorithm.
(c) What is its space complexity?
13
(d) Clearly mention the data structure(s) used by your algorithm.
(e) A vertex c is called a center of a tree T if the distance from c to
its most distant vertex is the minimum among all vertices in V .
Write an algorithm to determine and report a center of the given
tree T .
C21. (a) Assume you have a chocolate bar containing a number of small
identical squares arranged in a rectangular pattern. Our job is
to split the bar up until each piece is one of the small squares
14
by breaking along the lines between the squares. We obviously
want to do it with the minimum number of breakings. How many
breakings will it take?
(b) Consider that the chocolate bar has n breaking lines along the
length and m breaking lines along the breadth. Write the pseu-
docode of an algorithm that will take n, m as inputs and print
the line numbers of the lines along which your strategy does the
breaking of the chocolate.
C23. Consider a hypothetical gate G(A, B, C) for which the Karnaugh map
is given in Figure 4.
15
Determine the value of k that achieves minimum address decoding
time. Justify your answer. Assume that the time complexity of the
decoder is measured by the number of output lines of that decoder.
Explain with a diagram how to solve the aforementioned decoding
problem if n = 17.
C25. Let C denote a logic block that is capable of comparing two 4-bit 2’s
complement numbers A (a3 , a2 , a1 , a0 ) and B (b3 , b2 , b1 , b0 ), where
ai , bi ∈ {0, 1} for i = 0, 1, 2, 3. The circuit C has eight input lines
a3 , a2 , a1 , a0 , b3 , b2 , b1 , b0 , and three output lines E, L, G (Equal: E;
Less than: L; Greater than: G). For example, if A > B, then the
outputs should be E = 0, L = 0, and G = 1.
Write the Boolean equations for the three outputs E, L, and G.
C26. A Boolean function f is said to be positive unate if f can be expressed
in a form where all the variables appear in uncomplimented form, and
only the AND and OR Boolean operators are used. For example, the
function g1 = X1 X2 + X2 X3 is positive unate but g2 = X1 X2 + X̄2 X3
is not. Consider the following circuit in Figure 5 and determine which
of the two functions f1 and f2 are positive unate.
Y f1
X
Y
f2
16
the above scenario. Justify whether this circuit involves the minimum
number of NAND gates.
C29. (a) Write the smallest real number greater than 6.25 that can be
represented in the IEEE-754 single precision format (32-bit word
with 1 sign bit and 8-bit exponent).
(b) Convert the sign-magnitude number 10011011 into a 16-bit 2’s
complement binary number.
(c) The CPU of a machine is requesting the following sequence of
memory accesses given as word addresses: 1, 4, 8, 5, 20, 17, 19,
56. Assuming a direct-mapped cache with 8 one-word blocks,
that is initially empty, trace the content of the cache for the
above sequence.
17
C30. A machine M has the following five pipeline stages; their respective
time requirements in nanoseconds (ns) are given within parentheses:
F -stage — instruction fetch (9 ns),
D-stage — instruction decode and register fetch (3 ns),
X-stage — execute/address calculation (7 ns),
M -stage — memory access (9 ns),
W -stage — write back to a register (2 ns).
Assume that for each stage, the pipeline overhead is 1 ns. A program
P having 100 machine instructions runs on M, where every 3rd in-
struction needs a 1-cycle stall before the X-stage. Calculate the CPU
time in micro-seconds for completing P .
C32. Add the following two floating point numbers A and B given in IEEE-
754 single precision format and show the sum S in the same format.
A: 0000011000100 0000 000000000000001
B: 1000011000100 0000 000000000000001
C34. The access time of a cache memory is 100 ns and that of main memory
is 1000 ns. It is estimated that 80% of the memory requests are for
read and the remaining 20% are for write. The hit ratio for read access
is 0:9. A write through procedure is used.
(a) What is the average access time of the system considering only
memory read cycles?
(b) What is the average access time of the system considering both
read and write requests?
18
C35. Consider a machine with four registers (one of which is the accumulator
A) and the following instruction set.
• LOAD R and STORE R are indirect memory operations that load
and store using the address stored in the register R. Thus, LOAD
R loads the contents of memory[R] into A and STORE R stores the
contents of A in memory[R].
• MOV R1 R2 copies the contents of register R1 into register R2.
• ADD R and SUB R operate on the accumulator and one other reg-
ister R, such that A = A op R.
• LDC n stores the 7-bit constant n in the accumulator.
• BRA, BZ, and BNE are branch instructions, each taking a 5-bit
offset.
Design an instruction encoding scheme that allows each of the above
instructions (along with operands) to be encoded in 8 bits.
C37. The average memory access time for a microprocessor with first level
cache is 3 clock cycles.
• If data is present in the cache, it is found in 1 clock cycle.
• If data is not found in the cache, 100 clock cycles are needed to
get it from off-chip memory.
It is desired to obtain a 50% improvement in average memory access
time by adding a second level cache.
• This second level cache can be accessed in 6 clock cycles.
• The addition of this second level cache does not affect the first
level cache.
• Off-chip memory accesses still require 100 clock cycles.
To obtain the desired speedup, how often must data be found in the
second level cache?
19
C38. Two modules M1 and M2 of an old machine are being replaced by
their improved versions M3 and M4 , respectively in a new machine.
With respect to the old machine, the speed-up of these modules (M3
and M4 ) are 30 and 20, respectively. Only one module is usable at
any instant of time. A program P , when run on the old machine, uses
M1 and M2 for 30% and 20% of the total execution time, respectively.
Calculate the overall speed-up of P when it is executed on the new
machine.
C39. The page size in a system is increased while keeping everything else
(including the total size of main memory) the same. For each of the
following metrics below, explain whether its value is generally expected
to increase, decrease, or not change as a result of this increase in page
size:
(a) size of the page table of a process;
(b) TLB hit rate.
20
memory once allocated to a process is no longer available during
the entire span of the above sequence.
(b) Calculate the total memory wasted due to fragmentation in your
memory allocation by the above scheme.
C42. Figure 7 pictorially shows the layout of a file descriptor of a file system.
It uses 4 direct, 1 indirect, and 1 doubly indirect block addresses. If
the size of a disk block is 64 bytes and the size of each disk block
address is 8 bytes, calculate the maximum possible file size this file
system may have. Give the answer in the form of a × 2A , where a (not
divisible by 2) and A both denote integers.
21
C43. Two processes P1 and P2 have a common shared variable count. While
P1 increments it, P2 decrements it. Given that R0 is a register, the
corresponding assembly language codes are:
P1 : count++ P2 : count–
MOV count R0 MOV count R0
ADD #1 R0 SUB #1 R0
MOV R0 count MOV R0 count
Give an example to justify whether a race condition may occur if P1
and P2 are executed concurrently.
C44. Consider the following solution to the critical section problem for two
processes. The two processes, P0 and P1 , share the following variables:
Does this solution satisfy the mutual exclusion, progress and bounded
waiting properties?
22
C45. Suppose that an operating system provides two functions, block()
which puts the calling process on the blocked queue, and wakeup(P)
which moves process P to the runnable queue if it is currently on the
blocked queue (otherwise, its behaviour is unpredictable).
Consider two processes A and B running the code given below. The
intended behaviour of the code is to have A and B run forever, alter-
nately printing their names on the screen.
void A() void B()
{ while(1) { { while(1) {
block(); printf("B");
printf("A"); wakeup(A);
wakeup(B); block();
} }
} }
(a) Construct a scenario in which the intended behaviour would not
be observed.
(b) Redesign the code using semaphore(s) so that it works correctly.
You should show the initialisation of the semaphore(s), and the
calls to wait() and signal() made by A and B.
A 1, 1, 2, 1, 3 1, 0, 2, 1, 1
B 2, 2, 2, 1, 0 2, 0, 1, 1, 0
C 2, 1, 3, 1, 0 1, 1, 0, 1, 0
D 1, 1, 2, 2, 1 1, 1, 1, 1, 0
23
C47. Consider a uniprocessor system with four processes having the follow-
ing arrival and burst times:
(a) Calculate the average waiting time and also the average
turnaround time if shortest (remaining) job first (SJF) schedul-
ing policy is used with pre-emption. Assume that the context
switching time is zero. Note that in SJF, if at any point there is
a tie, then the job that arrived earlier will get priority.
(b) Now consider the continuous arrival of new jobs at times 4, 5,
6, 7, . . . following P 4, with CPU burst times of 2 units each. In
this case, what will be the turnaround time of P 1? Justify your
answer.
C48. Let us consider the relation schema <CTHRSG>, where the attributes
are C ≡ Course, T ≡ Teacher, H ≡ Class Hour, R ≡ Classroom, S ≡
Student, G ≡ Grade. We assume the following:
• Each course is taught by one teacher.
• Only one course can be taught in a classroom at one time.
• A teacher can be in only one classroom at one time.
• Each student has one grade in each course.
• A student can be in only one classroom at one time.
(a) Write down the above statements in terms of functional depen-
dencies.
(b) Determine a candidate key for the schema <CTHRSG>.
(c) Show that the schema <CTHRSG> is not in BCNF. Decompose
it into schemas which are in BCNF.
(d) Justify whether the above decomposition is dependency preserv-
ing or not.
24
C49. (a) Consider the following relations:
Student(snum: integer, sname: string, major: string, level: string,
age: integer)
Class(name: string, meets at: string, room: string, fid: integer)
Enrolled(snum: integer, cname: string)
Faculty(fid: integer, fname: string, deptid: integer).
Write an SQL query to find the names of faculty members who
teach in every room in which some class is taught.
(b) Let R be a relation with functional dependencies F. For any
subset of attributes X ⊂ R, the closure of X is defined as the set
C51. Consider the relations r1(A, B, C), r2(C, D, E) and r3(E, F ). Assume
that the set of all attributes constitutes the primary keys of these rela-
tions, rather than the individual ones. Let V (C, r1) be 500, V (C, r2)
be 1000, V (E, r2) be 50, and V (E, r3) be 150, where V (X, r) denotes
the number of distinct values that appear in relation r for attribute
X . If r1 has 1000 tuples, r2 has 1500 tuples, and r3 has 750 tuples,
then give the ordering of the natural join r1 ./ r2 ./ r3 for its efficient
computation. Justify your answer.
25
C52. A school database maintains the following relations for its students,
teachers and subjects:
26
C53. Two queries equivalent to each other are specified for a relation
R(A, B, C, D, E, F ). The queries are:
C54. Recall the stop-and-wait and sliding window protocols for a packet-
based data transmission. The stop and wait protocol sends one packet
and waits for the acknowledgment to arrive. The waiting mechanism
results in wastage of network bandwidth. In order to improve the
bandwidth utilization, the sliding window protocol utilizes pipelined
communication where multiple packets are sent without waiting for
acknowledgements. In the latter case, each packet is stamped with
a sequence number. The sequence number in each packet helps the
sender to decide whether it should continue the transmission or wait
for acknowledgement. It also helps the receiver to arrange the packets
in order and to prepare acknowledgements.
Consider that a sliding window protocol is used for data transmission
between two stations, say P and Q, located at a distance of d km.
Assume that all the packets are k bits long. The propagation delay is t
sec/km and the channel capacity is b bits/sec. Calculate the minimum
number of bits required for the sequence number field in a packet for
maximum utilization of the bandwidth. Assume that the processing
delay is negligible.
C55. A block of bits with n rows and m columns uses horizontal and vertical
parity bits for error detection. If exactly 4 bits are in error during
transmission, derive an expression for the probability that the error
will be detected.
27
C56. In a computer network, 2k host computers H0 , H1 , . . . , H2k −1 are con-
nected via routers that are connected in the form of a binary tree. An
example is shown in Figure 8 below for k = 3. Each node labelled Ri
corresponds to a router at level 3 − i (i = 1, 2, 3); the nodes at the
leaf level correspond to the hosts.
R0
Level 3
R1 R1
Level 2
R2 R2 R2 R2
Level 1
H0 H1 H2 H3 H4 H5 H6 H7
All the lines are full-duplex, and routers are faster than the links. Also,
all links at the same level are of the same capacity. Traffic is always
routed via shortest path. Suppose the capacity of each link at level 1
is 1 Mbps.
(a) Find the minimum capacities to be assigned to the links at upper
layers i (1 < i ≤ k), such that the router R0 is never congested.
Prove the correctness of your result.
(b) With the link capacities found in (i), show that there always
exist traffic patterns that may congest any router Ri other than
R0 . Justify your answer.
C57. Consider a 100Mbps token ring network with 10 stations having a ring
latency of 50 µs (the time taken by a token to make one complete
rotation around the network when none of the stations is active). A
station is allowed to transmit data when it receives the token, and
it releases the token immediately after transmission. The maximum
allowed holding time for a token (THT) is 200 µs.
(a) Express the maximum efficiency of this network when only a sin-
gle station is active in the network.
(b) Find an upper bound on the token rotation time when all stations
are active.
(c) Calculate the maximum throughput rate that one host can achieve
in the network.
28
C58. Station A is sending data to station B over a full duplex error free chan-
nel. A sliding window protocol is being used for flow control. The send
and receive window sizes are 6 frames each. Each frame is 1200 bytes
long and the transmission time for such a frame is 70 µS. Acknowl-
edgment frames sent by B to A are very small and require negligible
transmission time. The propagation delay over the link is 300 µS.
What is the maximum achievable throughput in this communication?
C60. A heavily loaded 1 km long, 10 Mbps token ring network has a propaga-
tion speed of 200 meter per micro-second. Fifty stations are uniformly
spaced around the ring. Each data packet is 256 bits long, including 32
bits of header. The token is of 8 bits. What is the effective data rate
of the network assuming the stations always have packets to transmit?
29
II. Mathematics for Computer Science
X
n X
n
MC3. Let f (x) = j
aj x and b(x) = bj xj , where aj , bj ∈ Z, j = 0, . . . , n.
j=0 j=0
For m ∈ N, we say f ≡ g mod m if aj = bj mod m for 0 ≤ j ≤ n.
For an odd prime p > 0, let
Prove that
(a) the polynomial f (x) − g(x) has degree p − 2, and
(b) f ≡ g mod p.
n
MC4. For n ≥ 1, let fn = 22 + 1. Show that if m and n are relatively
prime then fm and fn are relatively prime. Hence show that there are
infinitely many primes.
MC5. Show that for n ≥ 2, 1 + 1/2 + · · · + 1/2n is not an integer. You may
use the fact that there is a prime p between n and 2n for n ≥ 2.
(hint: Show that such a prime divides the denominator of 1 + 1/2 + · · · + 1/2n.)
MC6. Let p be a prime and let A = {1, 2, . . . , p − 1}. Prove that there is a
bijection f from A onto A such that kf (k) ≡ 1 (mod p) for each k ∈ A.
Hence deduce that if p is an odd prime, then p divides the numerator
of 1 + (1/2) + · · · + (1/(p − 1)).
30
MC7. Let p be a prime number. What is the largest power of p that divides
p2 ! ?
MC8. Show that the 100 digit number 11 · · · 1 is divisible by the prime num-
ber 101.
MC10. If a and b are integers such that 9 divides a2 + ab + b2 then show that
3 divides both a and b.
MC11. Let c be a 3n digit number whose digits are all equal. Show that 3n
divides c.
MC12. Show that, for distinct positive integers m and n, the greatest common
m n
divisor of 22 + 1 and 22 + 1 is 1. Deduce that the number of prime
integers is infinite.
X
k
p π
sin−1 logn di = × k.
4
i=1
√
hint: sin−1 x + sin−1 1 − x2 = π
2
(p−1)!
MC14. Let p be a prime and r an integer, 0 < r < p. Show that r!(p−r)! is an
integer.
MC15. Show that if a prime number is divided by 30, then the remainder is
either one or a prime number.
√ √
MC16. Prove that n−1+ n + 1 is an irrational number for all positive
integers n.
31
MC17. Show that n5 and n have the same last digit for all positive integers
n.
q
3n−5
MC19. Find all the integers n for which n+1 is also an integer.
MC20. Let p, q be distinct odd primes. Prove that the equation x2 = 1 has
exactly four (distinct) solutions in the ring of integers modulo pq.
MC21. For any x ∈ R, let [x] be the greatest integer not exceeding x. Let m
be a positive integer. Show that
√ √ √
[(1 + 3)2m+1 ] = (1 + 3)m+1 + (1 − 3)m+1 .
MC22. Let m, n be natural numbers. Show that m and m4n+1 have same last
digit in their decimal expansions.
MC26. Find the number of squares in [0, 8] × [0, 8] ⊆ R2 whose vertices have
integer coefficients and the sides are parallel to the coordinate axes.
32
Xn
n m−1
MC27. (a) Show that = .
k k−1
m=k
(b) Prove that
n 1 n 1 n n−1 1 n 1 1 1
− + − · · · +(−1) = 1+ + +· · ·+ .
1 2 2 3 3 n n 2 3 n
MC28. Prove that any set of n2 + 1 points in a square with side length one
contains
√ two points with distance between them less than or equal to
2
n .
MC29. Let n be a positive integer and p a prime. Show that the number of
ordered basis of a vector space of dimension n over a field of order p is
MC34. Find all sets of consecutive natural numbers whose sum is 54.
33
MC35. If 70% of students in a class pass the algebra test, 75% pass the analysis
test, 80% pass the geometry test, and 85% pass the number theory test,
what is the least percentage of students who pass all four subjects?
S = {(a, b, c) ∈ N3 : a + b + c = 25},
MC37. Let r be a positive real number. Prove that among the numbers
r, 2r, . . . , (n − 1)r there is at least one number which differs from an
integer by at most n1 .
is divisible by 53.
MC41. There are 102 distinct points in the unit square [0, 1] × [0, 1]. Show
that there are at least two distinct points such that the square of the
distance between them is at most 0.02.
MC42. Suppose that there are n boxes labelled 1, 2, . . . , n and there are n balls
also labelled similarly. The balls are thrown into boxes completely
randomly so that each box receives one ball.
(a) How many possible arrangements of balls in boxes is possible?
(b) Find the probability that the ball labelled 1 goes into the box
labelled 1.
(c) Find the probability that at least one ball is in the box with the
same label.
34
MC43. Show that the number of bijections f of {1, 2, . . . , n} such that f (i) ̸= i
for any i is equal to
Xn
n!
(−1)j .
j!
j=0
MC44. Find the smallest integer n > 0 such that 2012 divides 9n − 1. (Hint:
251 and 503 are prime numbers).
MC45. Let pk be the k-th prime number. Show that there are infinitely many
k such that
pk+1 − pk > 2.
MC46. For a real number x, [x] denotes the largest integer less than or equal
to x.
(a) For reals x, y show that [x + y] − [x] − [y] is zero or one.
(b) For m ≥ 1 and a prime p, let αp (m) be the largest power of p
which divides m (i.e., pαp (m) divides m but pαp (m)+1 does not.) It
X∞
n log 2n
is known that αp (n!) = k
. Show that αp 2nn ≤ .
p log p
k=1
(hint: How many terms in the formula for αp (n!) are non-zero?)
35
(b) Suppose G′ is obtained from G by deleting all edges of the form
(x, y) where x ∈ X and y ∈ Y . Compute the number of distinct
vertex covers for G′ .
[ Recall that, for a graph G = (V, E), a subset V ′ of V is a vertex
cover, if for every e = (v1 , v2 ) ∈ E, either v1 ∈ V ′ or v2 ∈ V ′ . ]
MC49. Let G be a graph on n vertices and having m edges. Prove the following
statements.
(a) If the maximum degree of a vertex in G is ∆, then there is no
independent set in G containing more than n − m
∆ vertices.
(b) There is a bipartite subgraph of G that contains at least m/2
edges.
MC50. Construct a tree such that no matter how you colour its vertices prop-
erly using two colours (i.e. two adjacent vertices do not get the same
colour), every maximum independent set of the tree contains vertices
of both colours.
MC52. Let G be a graph in which every vertex has odd degree. Let u be a
vertex and C a connected component of G − u. Prove that u has an
odd number of neighbours in C if and only if |C| is odd.
36
MC53. A planar graph is said to be an outerplanar graph if it has a planar
drawing in which every vertex appears on the boundary of the outer
face. Let G be a planar graph. Show that if it is possible to add edges
to G in order to make it a planar graph that contains a Hamiltonian
cycle, then there exist two subgraphs G1 , G2 of G such that G1 and
G2 are both outerplanar and E(G) = E(G1 ) ∪ E(G2 ).
MC54. Construct a planar graph with as many vertices as possible that has
the property that it can be obtained by removing three edges from a
complete graph.
MC57. Consider an urn containing 10 red balls, 10 white balls, and 10 black
balls. Balls are drawn at random with replacement one by one. Let T
be the minimum number of draws required to get balls of three colours.
Find the distribution of T .
37
MC59. Suppose an urn contains w white balls, b black balls, and r red balls;
w, b, r > 0. Balls are drawn one by one without replacement and at
random until all balls are exhausted. Find the probability that, among
the three colours, the white balls are exhausted first.
MC60. Suppose there are five pairs of shoes in a closet, from which four shoes
are taken out at random. Calculate the probability that among these
four shoes, there is at least one complete pair.
MC63. Construct a finite state machine that accepts all the binary strings in
which the number of 1’s and number of 0’s are divisible by 3 and 2,
respectively.
38
MC64. Describe the language recognized by the following machine.
a
b
a b
b b
a a
a,b
MC66. Design a Turing machine that recognizes the unary language consisting
n
of all strings of 0’s whose length is a power of 2, i.e., L = {02 |n ≥ 0}.
MC67. Write a context-free grammar for the language consisting of all strings
over {a, b} in which the number of a’s is not the same as that of b’s.
MC68. Let the set D = {p | p is a polynomial over the single variable x, and
p has a root which is an integer (positive or negative)}.
(a) Design a Turing machine (TM) to accept D.
(b) Can D be decided by a TM? Justify your answer.
MC70. Write a regular expression for all strings of 0’s and 1’s in which the
total number of 0’s to the right of each 1 is even. Justify your answer.
39
MC71. Construct a deterministic finite automaton accepting the following lan-
guage:
{w ∈ {0, 1}∗ : w has an equal number of 01’s and 10’s }.
For example, 101 is in the language because it contains one instance
of 10 and one instance of 01 as well.
40
III. Mathematics
Unless otherwise specified,
N denotes the set of positive integers;
Z denotes the set of integers;
Q denotes the set of rational numbers;
R denotes the set of real numbers;
C denotes the set of complex numbers.
R∞
M2. Define f (x) = ex /2 x e−t /2 dt for x > 0. Show that 0 < f (x) < 1/x
2 2
a2n + b2n a n + bn
0 < b1 < a1 , an+1 = and bn+1 = for n ∈ N.
a n + bn 2
Show that both sequences are monotone and they have the same
limit.
(b) Let the polynomial fn (x) = xn + a1 xn−1 + · · · + an−1 x + an , n ∈
N with all integer coefficients be such that fn (b1 ) = fn (b2 ) =
fn (b3 ) = fn (b4 ) = fn (b5 ) = 19 for five distinct integers b1 , b2 , b3 , b4
and b5 . How many different integer solutions exist for fn (x) = 23?
Justify your answer.
41
(c) Consider the matrix
1 3 2
A=
0 4 5 .
0 0 9
How many square roots does A have? Justify your answer.
is convergent.
for all n = 0, 1, 2, . . ., then show that f (x) = 0 for all x ∈ [0, 1].
42
(b) Let f : [0, 1] → R be continuous over [0, 1], differentiable over
(0, 1), f (0) = 0, and 0 ≤ f ′ (x) ≤ 2f (x).
Show that f is identically 0.
(c) Let f : [0, 1] → R be a continuous function. Show that
Z 1
lim (n + 1) xn f (x)dx = f (1).
n→∞ 0
M9. (a) Find the number of positive integers with k digits, that do not
contain the digit 7.
(b) Let S denote the set of all positive integers that do not contain
the digit 7. Prove that the infinite series
X1
n
n∈S
converges.
M10. (a) Let x be an irrational number. Show that for any positive integer
k ≥ 1, there exists δk > 0, such that the open interval (x − δk , x +
δk ) does not contain any rational number of the form kp , where p
is an integer.
(b) Consider the function f defined on [1, 2] as follows:
0 if x ∈ [1, 2] is irrational
p
k if x ∈ [1, 2] is a rational k where p and
f (x) = 1
k are integers prime to each other
43
M11. (a) Show that for every θ ∈ (0, π/2), there exists a unique real xθ
such that
3
(sin θ)xθ + (cos θ)xθ = .
2
(b) Find all possible real values of α for which the following improper
integral exists: Z 1
|x|α dx.
−1
f (xn ) − f (yn )
lim = f ′ (c).
n→∞ x n − yn
M14. Let
f : R2 → R have continuous partial derivatives and satisfy
∂f
∂xj (x) ≤ K for all x = (x1 , x2 ), j = 1, 2. Prove that
√
f (x) − f (y) ≤ 2K∥x − y∥.
p
Here, ∥(x1 , x2 )∥ = x21 + x22 .
44
M17. Let X be a set containing at least two elements and G be a group
with identity element e. Suppose that there is a map α : G × X → X.
Let us write α(g, x) as g · x. Assume that the following properties are
satisfied by α:
• e · x = x for all x ∈ X;
• g1 · (g2 · x) = (g1 g2 ) · x for all g1 , g2 ∈ G and x ∈ X;
• given (x1 , x2 ) ∈ X × X and (y1 , y2 ) ∈ X × X with x1 ̸= x2 ,
y1 ̸= y2 , there is a g ∈ G such that g · x1 = y1 and g · x2 = y2 .
(The case xi is same as some yj for i, j = 1, 2 is allowed).
For x ∈ X, define
Gx := {g ∈ G : g · x = x}.
45
n
M19. Let G be a group of order n, H a subgroup of G of order m, k =
m
k!
and Sk the symmetric group on k symbols. Assuming < n, show
2
that G has a nontrivial proper normal subgroup.
R[X]
M23. Examine whether there is a polynomial f (X) ∈ R[X] such that
(f (X))
is isomorphic as rings to the product ring C × C.
46
M24. Prove that the following two groups are isomorphic:
C[X, Y ]
M25. Let A = , and x, y denote the images of X, Y in A
(X 2 + Y 2 − 1)
respectively. If u = x + iy, then prove that
(a) u is a unit in A, and
(b) u − i generates a maximal ideal of A.
M26. Find all ring automorphisms of Q [X] where Q denotes the field of
rational numbers.
M27. In the additive group of rational numbers, show that the group gener-
ated by any two elements is cyclic.
M29. Let Z[X] denote the ring of polynomials in X with integer coefficients.
Find an ideal I in Z[X] such that Z[X]/I is a field of order 4.
M30. Let F be a field whose multiplicative group is cyclic. Show that there
exists a prime number p such that px = 0 for each x in F .
M32. If m and n are distinct natural numbers, then show that the abelian
groups Zm and Zn are not isomorphic.
47
M34. Let I be the ideal generated by X − 3 and 7 in the polynomial ring
Z[X]. Show that, for each f (X) ∈ Z[X], there exists a unique integer
a, 0 ≤ a ≤ 6, such that f (X) − a ∈ I.
M35. If G is a group of order 111 with exactly two elements of order 3 then
show that G is cyclic.
M38. Show that the additive group of complex numbers is isomorphic to the
additive group of real numbers.
(Hint : Consider these as vector spaces over an appropriate field.)
is even.
48
M42. Let ψ be an automorphism of the additive group Z/77Z of the integers
mod 77. Show that ψ 60 is the identity automorphism (here ψ 60 means
the 60-fold composition of ψ with itself).
M43. Let G be a finite group. Assume that G has exactly one element a of
order 2. Then show that Y
g = a.
g∈G
M45. Let f , g be two polynomials in Z [x]. Prove that the ideal generated
by them in Z [x] contains a non-zero integer if and only if they are
relatively prime in Q [x].
M50. Show that the ideal generated by 2 and x in the ring Z [x] of polyno-
mials over the ring of integers cannot be generated by one element.
M51. Can the ideal I = f : [0, 1] → R, f 12 = 0 in the ring R of all
functions from [0, 1] to R be generated by one element?
49
M52. Let K be a subfield of C that is not contained in R. Show that K is
dense in C.
M53. Let g be an element of order 143 in a group G. Show that there are
unique elements g1 , g2 in G satisfying:
I. g = g1 g2 = g2 g1 ,
II. Order of g1 = 11, Order of g2 = 13.
M54. Let A be any ring without zero divisors; that is, xy = 0 implies either
x = 0 or y = 0. If a, b ∈ A satisfy am = bm , an = bn for two fixed
relatively prime natural numbers m, n prove that a = b.
M57. Let Q denote the field of rational numbers. Let I be the principal ideal
in the polynomial ring Q[x] generated by the polynomial f (x) = x4 −1,
i.e.,
I = {g(x)f (x)|g(x) ∈ Q[x]} .
Show that I is contained in exactly three prime ideals of Q[x].
B = {Id, (1, 2)(3, 4), (1, 3)(2, 4), (1, 4)(2, 3)}.
50
M60. Let R be a Ring with identity. Let I and J be two ideal in R. Suppose
Φ : R → R/I × R/J defined by Φ(a) = (a + I, a + J) for a ∈ R, is a
ring isomorphism. Show that I ∩ J = {0} and I + J = R.
M61. Show that if the multiplicative group of a field in cyclic, then the field
in finite.
M62. Show that every finitely generated subgroup of the additive group of
rational numbers is cyclic.
M63. If I is a maximal ideal of the polynomial ring Z[X], show that Z[X]/I
is a finite field.
M64. Let Sn be the group of all permutations of the set {1, 2, . . . , n}. Find
the number of conjugates of the n-cycle taking i to i + 1 for 1 ≤ i ≤
(n − 1) and n to 1.
√ √
M66. Show that there is no field isomorphism between Q( 2) and Q( 3).
Are they isomorphic as vector spaces over Q?
M67. Let Q, R denote the fields of rational numbers and real numbers re-
spectively. Which of the following rings are not isomorphic.
(a) Q[x]/ < x2 + 1 > and Q[x]/ < x2 + x + 1 >.
(b) R[x]/ < x2 + 1 > and R[x]/ < x2 + x + 1 >.
Justify your answer.
51
M68. Let S4 denote the group of permutations of {1, 2, 3, 4} and let H be
a subgroup of S4 of order 6. Show that there exists an element i ∈
{1, 2, 3, 4} which is fixed by each element of H.
M69. Let P (x), Q(x) be two distinct polynomials (over R) with degree of P
and Q being at most (d − 1). Let a0 , . . . , an−1 be distinct elements of
R. Prove that |{i : P (ai ) ̸= Q(ai )}| ≥ n − d + 1.
52
M75. Let A be a real symmetric m × m matrix with m distinct eigenvalues
and v1 , . . . , vm be the corresponding eigenvectors. Let C be an m × m
matrix satisfying ⟨Cvj , vj ⟩ = 0 for 1 ≤ j ≤ m. Prove that there exists
an m × m matrix X such that AX − XA = C.
M79. Let Rn denote the n dimensional real vector space. Let A, B be two
linear transformations on Rn such that A ◦ A = A and B ◦ B = B,
where ◦ stands for composition of linear transformations. Show that
the ranges of A − A ◦ B and B − A ◦ B have only the zero vector in
common.
M80. Let V be the real vector space consisting of continuous real valued
functions on R. Show that the subset {sin x, cos x, ex } of V is linearly
independent.
M81. Let L and T be two linear transformations from a real vector space
V to R such that L (v) = 0 implies T (v) = 0. Show that T = cL for
some real number c.
53
M82. Let x1 , x2 , x3 , x4 be vectors in Rn such that the inner products ⟨xi , xj ⟩,
i ̸= j, are strictly negative. Show that any three of the vectors
x1 , x2 , x3 , x4 are linearly independent.
M83. Let A be an n×n square matrix such that A2 is the identity. Show that
any n × 1 vector can be expressed as a sum of atmost two eigenvectors
of A.
M85. Let
0 1 0 0
0 0 1 0
B=
.
0 0 0 1
0 0 0 0
Show that, for each nonzero scalar λ, (λI − B)−1 = Pλ (B) for some
polynomial Pλ (X) of degree 3.
M87. Let x and y be non-zero vectors in an inner product space over the
field of real numbers. Then ∥x + y∥ = ∥x∥ + ∥y∥ if and only if x = αy
for some positive real number α.
M88. Suppose that A is a 2 × 2 matrix over reals such that An = I for some
integer n. Show that trace of A is atmost 2.
54
M91. If A is an n × n upper triangular matrix with all diagonal entries 1,
find the inverse of A as a polynomial in A.
span {Dk x : 0 ≤ k ≤ n − 1} = Rn
55
M98. Let B, C be two invertible n × n complex matrices such that BC =
qCB for some complex number q. Show that q m = 1 for some m ≥ 1.
(Hint: Consider the eigenvalues of BC and CB.)
m(Am m m m 2 m
0 + A1 ) = (A0 + A1 ) + (A0 + ωA1 ) + (A0 + ω A1 ) +
· · · + (A0 + ω m−1 A1 )m .
M102. Let A and!B be n × n matrices with real entries. Show that the matrix
A I
has rank n if and only if A is nonsingular and B = A−1 .
I B
M106. Let A be a square matrix such that Ak = 0 for some k > 0. Prove
that there exists an invertible matrix B such that BAB −1 is upper
triangular with diagonal entries zero.
56
M107. Let A be an n × n integer matrix whose columns are pairwise distinct.
Show that there is a row in A, whose removal results in an (n − 1) × n
matrix with the same property.
M108. Let Sn denote the group of all permutations of {1, 2, . . . , n}. For any
σ ∈ Sn , denote by Pσ the linear transformation on Rn given by
x1 xσ−1 (1)
x2
Pσ =
x σ (2)
−1
.. ..
. .
xn xσ−1 (n)
M110. (a) Show that a connected subset of a metric space is either a single-
ton or uncountable.
(b) Let A be a connected subset of a connected topological space X.
Suppose that B is a clopen (closed and open) subset of X \ A in
the subspace topology of X \ A. Prove that A ∪ B is connected.
M111. (a) Suppose A and B are closed subsets of a topological space such
that A ∩ B and A ∪ B are connected. Prove that A and B are
connected.
(b) Demonstrate that the conclusion may not hold if the assumption
of A and B being closed subsets, is dropped.
57
M112. Let L1 be the line y = 1, L−1 be the line y = −1, and for every n ≥ 1,
Rn be the rectangle
Rn = {−n, n} × [−1 + n1 , 1 − n1 ] ∪ [−n, n] × {−1 + n1 , 1 − n1 } .
Define [
X = L1 ∪ L−1 ∪ Rn ,
n≥1
which is equipped with the subspace topology from R2 (see the figure
below).
y
L1
R1 R2 · · · Rn x
L−1
M113. Prove that there cannot be any topological space X such that R is
homeomorphic to X × X with the product topology.
58
M114. Let (X, d) be a compact metric space, and f : X → X a function such
that
d(f (x), f (y)) < d(x, y) for all x, y ∈ X, x ̸= y.
(a) Show that g(x) = d(x, f (x)) is a continuous function on X.
(b) Show that there is a point x0 ∈ X such that f (x0 ) = x0 .
M115. Let (X, d) be a metric space. Assume that X is countable and has at
least two points. Show that X is not connected.
M116. Let > 0 be a real number. Let d denote the Euclidean metric on Rn ,
the n dimensional real vector space. Show that there cannot exist an
uncountable subset S of Rn such that d (s, t) > for all s ̸= t in S.
M118. Let A be a closed subset of the real numbers R with respect to its
usual metric topology. Prove that there exists a countable subset of A
whose closure is A.
M121. Let X be a compact Hausdorff space. Assume that the vector space
of real-valued continuous functions on X is finite dimensional. Show
that X is finite.
59
M122. Let X be a metric space. Assume that, for each positive real number
r, the closure of each open ball of radius r is compact. Show that X
is complete.
M127. Let X be an infinite set and let {dn }n≥1 be a sequence of metrics on
X such that dn (x, y) ≤ 1 for all x, y ∈ X and for all n ≥ 1. Show that
∞
X dn (x, y)
d(x, y) =
2n
n=1
for x, y ∈ X is a metric on X.
M128. Let X = [0, ∞). Define a metric d on X such that d(x, y) ≤ 1 for
all x, y ∈ X and such that the topology induced by d is same as the
relative real line topology on X.
60
M129. Let X = R\{0} be equipped with the relative real line topology and
let Y denote the curve Y = {(x, y) ∈ R2 : xy = 1} with the subspace
topology of the usual Euclidean topology on R2 . Prove that X is
homeomorphic to Y .
M132. Let
X = {{αn }n≥1 : αn ∈ R, lim αn = 0, sup |αn | ≤ 1}.
n→∞ n
Define a metric on X by
M134. Show that the set of all rational numbers with the usual topology is
not locally compact.
61
M137. Show that the complement of a non-empty compact subset of R is not
connected.
M141. Let
C = {(x, y) ∈ R2 | x3 = y 2 }.
Prove that R with its usual topology is homeomorphic to C with its
subspace topology induced from R2 .
62