Capstone Final Questions
Capstone Final Questions
( )
1
A. Θ(𝑛) .
B. Θ(𝑛) .
C. Θ(𝑛)
D. Θ(𝑛)
8. Let A be a square matrix of size n x n. Consider the following program. What is the expected
output?
C = 100
for i = 1 to n do
for j = 1 to n do
{
Temp = A[i][j] + C
A[i][j] = A[j][i]
A[j][i] = Temp - C
}
for i = 1 to n do
for j = 1 to n do
Output(A[i][j]);
A. The matrix A itself
B. Transpose of matrix A
C. Adding 100 to the upper diagonal elements and subtracting 100 from diagonal elements of
A
D. None of the above
(A) Θ(n4)
(B) Θ(n2)
(C) Θ(n2 log n)
(D) Θ(n3)
11. What’s the solution to the recurrence relation 𝑇(𝑛) = 𝑇 ( )+ 1
𝑛
2
A. Θ(𝑛)
B. Θ(log 𝑙𝑜𝑔 𝑛)
C. Θ(log 𝑙𝑜𝑔 log 𝑙𝑜𝑔 𝑛)
D. Θ(𝑛 log 𝑙𝑜𝑔 𝑛)
12. The value of j at the end of the execution of the following C program.
int incr (int i) {
static int count = 0;
count = count + i;
return (count); }
main () {
int i,j;
j = incr(i);
A. 10
B. 4
C. 6
D. 7
14.
The set of all tuples that must be additionally deleted to preserve referential integrity when the
tuple (2,4) is deleted is:
17.
Which of the following is a correct attribute set for one of the tables for the correct answer to the
above question?
(a) {M1, M2, M3, P1}
(b) {M1, P1, N1, N2}
(c) {M1, P1, N1}
(d) {M1, P1}
18. A relational schema for a train reservation database is given below.
Passenger (pid, pname, age)
Reservation (pid, class, tid)
Table: Passenger
pid pname age
-----------------
0 Sachin 65
1 Rahul 66
2 Sourav 67
3 Anil 69
Table : Reservation
pid class tid
---------------
0 AC 8200
1 AC 8201
2 SC 8201
5 AC 8203
1 SC 8204
3 AC 8202
What pids are returned by the following SQL query for the above instance of the tables?
SELECT pid
FROM Reservation ,
WHERE class ‘AC’ AND
EXISTS (SELECT *
FROM Passenger
WHERE age > 65 AND
Passenger. pid = Reservation.pid)
(A) 1, 0
(B) 1, 2
(C) 1, 3
(S) 1, 5
A) Θ(𝑛log𝑛)
B) Θ(𝑛)
C) Θ(log𝑛)
D) Θ(1)
21. Which one of the following is the recurrence equation for the worst case time complexity of the
Quicksort algorithm for sorting n ( ≥2 ) numbers? In the recurrence equations given in the
options below, c is a constant.
a) T(n) = 2T(n/2) + cn
b) T(n) = T(n - 1) + T(1) + cn
c) T(n) = 2T(n - 1) + cn
d) T(n) = T(n/2) + cn
22. Let S be an NP-complete problem and Q and R be two other problems not known to be in NP. Q
is polynomial time reducible to S and S is polynomial-time reducible to R. Which one of the
following statements is true?
a) R is NP-complete
b) R is NP-hard
c) Q is NP-complete
d) Q is NP-hard
23. Consider the following C functions:
C) Θ(𝑛)𝑎𝑛𝑑Θ(2𝑛)
D) Θ(2n)𝑎𝑛𝑑Θ(2𝑛)
24. Ram and Shyam have been asked to show that a certain problem Π is NP-complete. Ram shows a
polynomial time reduction from the 3-SAT problem to Π, and Shyam shows a polynomial time
reduction from Π to 3-SAT. Which of the following can be inferred from these reductions ?
A) Π is NP-hard but not NP-complete
B) Π is in NP, but is not NP-complete
C) Π is NP-complete
D) Π is neither NP-hard, nor in NP
int gcd(n,m)
if (n % m == 0) return m;
n = n % m;
return gcd(m,n);
return (1);
A )O(n)
B) O(n log n)
C) O(n2)
D) O(2n)
Which one of the following represents the time complexity of the algorithm?
A) Θ(𝑛)
B) Θ(𝑛log𝑛)
C) Θ(𝑛2)
2
D) Θ(𝑛 log𝑛)
29. The graph shown below has 8 edges with distinct integer edge weights. The minimum spanning
tree (MST) is of weight 36 and contains the edges: {(A, C), (B, C), (B, E), (E, F), (D, F)}. The edge
weights of only those edges which are in the MST are given in the figure shown below. The
minimum possible sum of weights of all 8 edges of this graph is ___________.
30. Identify the correct sequence in which the following packets are transmitted on the
network by a host when a browser requests a web page from a remote server, assuming
that the host has just been restarted
a. HTTP GET request, DNS query, TCP SYN
b. DNS query, HTTP GET request, TCP SYN
c. DNS query, TCP SYN, HTTP GET request
d. TCP SYN, DNS query, HTTP GET request
31. If an Internet Service Provider (ISP) has the following chunk of CIDR-based IP
addresses available with it:245.248.128.0/20 and the ISP wants to give half of this chunk of
address to Organization A, and a quarter to Organization B, while retaining the remaining
with itself. Then, which among the following is a valid allocation of addresses to A and B?
a. 245.248.132.0/22 and 245.248.132.0/21
b. 245.248.136.0/21 and 245.248.128.0/22
c. 245.248.128.0/21 and 245.248.128.0/22
d. 245.248.136.0/22 and 245.248.132.0/21
32. Which of the following statements is NOT true about Ring topology ?
a. The data flows in anti-clockwise direction
b. The data flows in endless loop
c. It has not terminated end
d. It is unidirectional
33. Which of the following fields in an IP header is/are always modified by any router
before it forwards the IP packet?
a. Source IP address
b. TTL
c. Protocol
d. Header Checksum
34. Which of the following is/are example(s) of stateful application layer protocols?
a. I and II only
b. II and III only
c. II and IV only
d. IV only
35. Consider the following sequence of instructions to be executed in a pipelined processor: [GATE
CSE 2024]
I1: DIV R3, R1, R2
I2: SUB R5, R3, R4
I3: ADD R3, R5, R6
I4: MUL R7, R3, R8
Which of the following statements is/are TRUE?
a) There is a RAW dependency on R3 between I1 and I2
b) There is a WAR dependency on R3 between I1 and I3
c) There is a RAW dependency on R3 between I2 and I3
d) There is a WAW dependency on R3 beteween I3 and I4,
36. For computers based on three-address instruction formats, each address field can be
used to specify which of the following:
(S1) A memory operand
(S2) A processor register
(S3) An implied accumulator register
a)Either S1 or S2
b)Either S2 or S3
c)Only S2 and S3
d)all of S1,S2 and S3.
37. The decimal value 0.5 in IEEE single precision floating point representation has [GATE
CSE 2012]
a) fraction bits of 0000…00000 and exponent value of 0
b) fraction bits of 0000…00000 and exponent value of -1
c) fraction bits of 1000…00000 and exponent value of 0
d) no exact representation
38. Consider functions Function_1 and Function_2 expressed in pseudocode as follows:
1. Function_1 | Function_2
2. while n > 1 do | for i = 1 to 100 * n do
3. for i = 1 to n do | x = x + 1;
4. x = x + 1; | end for
5. end for |
6. n = ⌊n/2⌋; |
7. end while |
Let F1(N) and F2(N) denote the number of times the statement “x = x + 1” is executed
in Function_1 and Function_2, respectively.
Which of the following statements is/are TRUE?
39. The number of distinct minimum-weight spanning trees of the following graph is
A. 6
B. 9
C. 12
D. 4