Professional Documents
Culture Documents
GATE 2021 CS Set-1
GATE 2021 CS Set-1
Which of the following is the CORRECT observation about the above two sentences?
Ans: Option 2
Explanation:
ii). Babu invited Danish to his home because he enjoys playing chess.
This statement is ambiguous as there is no guarantee that Danish knows playing chess.
2.
Q --- 25 10,000
Details of prices of two items P and Q are presented in the above table. The ratio of cost of item
P to cost of item Q is 3:4. Discount is calculated as the difference between the marked price and
1
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
the selling price. The profit percentage is calculated as the ratio of the difference between selling
(
price and cost, to the cost 𝑃𝑟𝑜𝑓𝑖𝑡 % =
𝑆𝑒𝑙𝑙𝑖𝑛𝑔 𝑝𝑟𝑖𝑐𝑒−𝐶𝑜𝑠𝑡
𝐶𝑜𝑠𝑡 )
× 100 .
1. 25
2. 5
3. 10
4. 12.5
Answer : 3
Explanation:
Given that
P 5400 -- 5860
Q 7200 25 10,000
𝑆𝑃−7200
⇒ 25 = 7200
× 100
𝑆𝑃 = 9000
⇒Marked price is 10000 and the selling price is 9000. Then percentage of discount given
10000−9000
= 10000
× 100
1000
= 10000
× 100
= 10%
2
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Among the options below, an acceptable value for the total number of students in the class is:
1. 37
2. 73
3. 21
4. 50
Answer : 4
Explanation :
Number of boys = 7x
Number of girls = 3x
Answer is 50.
4. A polygon is convex if, for every pair of points, P and Q belonging to the polygon, the line
segment PQ lies completely inside or on the polygon.
3
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Answer : 1
Explanation :
◦
The angle Ө is more than 180 , so it is not a convex polygon.
5.
4
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
A circular sheet of paper is folded along the lines in the directions shown. The paper, after being
punched in the final folded state as shown and unfolded in the reverse order of folding, will look
like _______.
5
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Answer : 2
Explanation :
1. 3π
π
2. 2
3
3. π
9
4. π
Answer : 4
Explanation :
Size of cube = 1 cm
3
Volume of cube = 1 = 1
⇒ Rectangle M will be
6
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
3 2
2
Volume of cylinder = π𝑟 ℎ = π ( ) (1) =
π
9
π
Which one of the following options maintains a similar logical relation in the above sentence?
1. Hospital, library
2. Medicine, grammar
3. Plan, outline
4. Doctor, book
Ans: Option 4
Explanation:
The given statement is to fill the relationship of the subject and the action done by the subject.
8. There are five bags each containing identical sets of ten distinct chocolates. One chocolate is
picked from each bag.
7
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
1. 0.81225
2. 0.4235
3. 0.6976
4. 0.3024
Answer : 3
Explanation :
There are 5 bags having identical sets of 10 distinct chocolates. one chocolate is drawn from
each bag, probability to find at least 2 chocolate is identical
9. Some people suggest anti-obesity measures (AOM) such as displaying calorie information in
restaurant menus. Such measures sidestep addressing the core problems that cause obesity:
poverty and income inequality.
Ans: Option 1
Explanation:
The problems mentioned are poverty and income inequality. But AOMs are not addressing the
main problems directly. But it is a kind of generic step taken to address obesity. So AOMs are
only addressing the obesity problem superficially but not addressing the real problems.
8
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
10. Given below are two statements 1 and 2, and two conclusions I and II.
Based on the above statements and conclusions, which one of the following options is logically
CORRECT?
Answer : 4
Explanation :
9
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
for (loopIndex = 1; loopIndex <= n - 1; loopIndex++)
total = x * total + Y[loopIndex]
return total;
}
Let Z be an array of 10 elements with Z[i]=1, for all i such that 0 ≤ i ≤ 9. The value returned by
SimpleFunction(Z, 10, 2) is _______
Answer: 1023
Explanation:
n=10,x=2
total=2*3+Y[2]=6+1=7
total=2*7+Y[3]=14+1 =15
total= 2*15+Y[4]=30+1=31
total=2*31+Y[5]=62+1=63
total=2*63+Y[6]=126+1=127
Total =2*127+Y[7]=254+1=255
10
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
loopindex=8, 8<=9 condition is true then
total=2*255+Y[8]=510+1=511
total=2*511+Y[9]=1022+1=1023
12. The following relation records the age of 500 employees of a company, where empNo
(indicating the employee number) is the key:
∏𝑒𝑚𝑝𝑁𝑜(𝑒𝑚𝑝𝐴𝑔𝑒 ⋈ ρ𝑒𝑚𝑝𝑁𝑜1,𝑎𝑔𝑒1(𝑒𝑚𝑝𝐴𝑔𝑒))
(𝑎𝑔𝑒>𝑎𝑔𝑒1)
Answer : 3
Explanation :
The given relational algebra expression will result in employees whose age is not minimum. The
given conditional join, joins the relations if the age is greater than any of the ages mentioned in
the database.
11
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
13. A TCP server application is programmed to listen on port number P on host S. A TCP client
is connected to the TCP server over the network.
Consider that while the TCP connection was active, the server machine S crashed and rebooted.
Assume that the client does not use the TCP keepalive timer.
Answer : 1,2,3
Explanation:
1) True
Since broken connections can only be detected by sending data, the receiving side will
wait forever. This scenario is called a “half-open connection” because one side realizes
the connection was lost but the other side believes it is still active.
2) True
The situation resolves itself when client tries to send data to server over the dead
connection, and server replies with an RST packet (not FIN).
3) True
Yes, a TCP Server can listen to the same port number even after reboot. For example, the
SMTP service application usually listens on TCP port 25 for incoming requests. So, even
after reboot the port 25 is assigned to SMTP.
4) False
The situation resolves itself when client tries to send data to server over the dead
connection, and server replies with an RST packet (not FIN), causing client to finally to
close the connection forcibly.
FIN is used to close TCP connections gracefully in each direction (normal close of
connection), while TCP RST is used in a scenario where TCP connections cannot recover
from errors and the connection needs to reset forcibly.
12
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
a = b + c;
e = a + 1;
d = b + c;
f = d + 1;
g = e + f;
In a compiler, this code segment is represented internally as a directed acyclic graph (DAG). The
number of nodes in the DAG is _______
Answer : 6
2𝑥+22−4
lim 𝑥+3
𝑥 → −3
Answer : 0.25
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
13
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Explanation:
2𝑥+22−4
lim 𝑥+3
𝑥 → −3
0
It’s in 0
form, apply L-hospital rule i.e., differentiate numerator, denominator
1 −1/2
2
(2𝑥+22) ×2
lim 1
𝑥 → −3
Substitute -3
1 −1/2
2
(− 6 + 22) ×2
1 1 1 1
2
× × 2 = 8
×2 = 4
16
14
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Which of the following sequences of key insertions can cause the above state of the hash
table (assume the keys are in decimal notation)?
1. 10, 9, 6, 7, 5, 13
2. 9, 5, 13, 6, 10, 14
3. 9, 5, 10, 6, 7, 1
4. 5, 9, 4, 13, 10, 7
Answer : 1
Explanation :
The key insertions 10, 9, 6, 7, 5, 13 would result in the state of the given hash table.
Number 10 9 6 7 5 13
The keys are inserted into the main hash table based on their 2 least significant bits.
→ The keys 6 and 10 will be inserted in the table with entry “10”
Empty 9 5 13 10 6 7
10 01 01 01 11 01 10 10 01 10 01 11
00 01 10 11
→ Now the entry index 01 has collisions. Check the 3rd least significant bit of the keys 9,5,13. The 3rd
least significant bit of the key is 0. Hence, key “9” placed as the left child of “01”. There will be collisions
again in between the keys 5 and 13 which need to splitted.
Now check the 4th least significant bit of keys 5 and 13. The key 5 is placed as a left child because the 4th
least significant is “0” and the key “13” is placed as right child because its 4th least significant is 1.
15
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
→ Now the entry index 10 has a collision. Check the 3rd least significant bit of the keys 10 and 6. The 3rd
last significant bit of the key is 0. Hence, “10” is placed as the left child of index “10”.
The 3rd least significant value of “6” is 1. So, we are placed as the right child of index ”10”.
17. Let p and q be two propositions. Consider the following two formulae in propositional logic.
𝑆1: (¬𝑝 ∧ (𝑝 ∨ 𝑞) → 𝑞)
𝑆2: 𝑞 → (¬𝑝 ∧ (𝑝 ∨ 𝑞))
Answer : 4
Explanation :
A tautology is a formula which is "always true" . That is, it is true for every assignment
of truth values to its simple components.
Method 1:
S1: (~p ^ (p Vq)) →q
The implication is false only for T->F condition.
Let's consider q as false, then
(~p ^ (p Vq)) will be (~p ^ (p VF)) = (~p ^ (p)) =F.
It is always F->F which is true for implication. So there are no cases that return
false, thus its always True i.e. its Tautology.
S2:
q->(~p ∧ (p Vq))
Method 2:
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
16
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
𝑆1: (¬𝑝 ∧ (𝑝 ∨ 𝑞) → 𝑞)
𝑆2: 𝑞 → (¬𝑝 ∧ (𝑝 ∨ 𝑞))
𝑝 𝑞 ¬𝑝 𝑝∨𝑞 ¬𝑝 ∧ (𝑝 ∨ 𝑞) ¬𝑝 ∧ (𝑝 ∨ 𝑞) → 𝑞
T T F T F T
T F F T F T
F T T T T T
F F T F F T
𝑆1: Valid ✓
T T F T F F
T F F T F T
F T T T T T
F F T F F T
𝑆2:Not Valid since there is one False
Answer : 86
Explanation :
push(54) ⇒ 54
push(52)=> 54, 52(top)
pop() ⇒ 54 (top)
push(55)==> 54, 55(top)
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
17
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
push(62) ⇒ 54,55,62(top)
s=pop() ⇒ 62 will store into the variable s then s=62
19. Consider the following representation of a number in IEEE 754 single-precision floating
point format with a bias of 127.
18
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Here S, E and F denote the sign, exponent and fraction components of the floating point
representation.
The decimal value corresponding to the above representation (rounded to 2 decimal places) is
_______
Solution: -7.75
Explanation:
= 129- 127
=2
= (-1) 1 x 1.1111 x 22
= - (111.11)
= - (7 + 0.75)
= -7.7
___________________________________________________
20. Let the representation of a number in base 3 be 210. What is the hexadecimal representation
of the number?
1. 21
2. 528
3. D2
4. 15
Solution: D
Explanation:
19
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
On converting (210)3 in decimal, we will get:=>
2*32+1*3=2*9+3=2110
=>(15)16
____________________________________________________________________
21. Let 𝑟𝑖(𝑧) and 𝑤𝑖(𝑧) denote read and write operations respectively on a data item z by a
transaction 𝑇𝑖. Consider the following two schedules.
Answer: 1
Explanation:
S1:
20
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
S2:
22. A sender (S) transmits a signal, which can be one of the two kinds: H and L with
probabilities 0.1 and 0.9 respectively, to a receiver (R).
In the graph below, the weight of edge (u, v) is the probability of receiving v when u is
transmitted, where u, v ∈ {H, L}. For example, the probability that the received signal is L
given the transmitted signal was H, is 0.7.
If the received signal is H, the probability that the transmitted signal was H (rounded to 2
decimal places) is _______
Answer: 0.04
Solution:
Bayes theorem:
Probability of event A happening given that event B has already happened is
P(A/B) = P(B/A)*P(A) / P(B)
21
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Here, it is asked that P( H transmitted / H received).
S can send signal to H with 0.1 probability, S can send signal to L with 0.9 probability.
The complete diagram can be
P(H-r) = probability that H received = P( H received from H)+ P(H received from L)
It can be observed from the graph that H can receive in two ways (S to H to H) and (S to L to H)
The P(H_r) = 0.1*0.3 + 0.9*0.8= 0.03+0.72 = 0.75
23. In an undirected connected planar graph G, there are eight vertices and five faces. The
number of edges in G is ______
Answer : 11
22
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Explanation :
v-e+f=2
v is number of vertices
e is number of edges
f is number of faces including bounded and unbounded
8-e+5=2
=> 13-2 =e
The number of edges are =11
𝑛 𝑙𝑜𝑔 𝑛 𝑛
𝑓1 = 10 𝑓2 = 𝑛 𝑓3 = 𝑛
Which one of the following options arranges the functions in the increasing order of asymptotic
growth rate?
1. 𝑓2, 𝑓3, 𝑓1
2. 𝑓3, 𝑓2, 𝑓1
3. 𝑓2, 𝑓1, 𝑓3
4. 𝑓1, 𝑓2, 𝑓3
Answer : 1
Explanation :
Constant < logarithmic < linear < polynomial < exponential < factorial
F2 and F3 → Polynomial
F1 → Exponential
23
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Method-1:
Consider n=100
Method-2:
log(F1)=nlog10 (base 2)
log(F3)=sqrt(n)logn (base 2)
( )
25. In a pushdown automaton 𝑃 = 𝑄, Σ, Γ, δ, 𝑞0, 𝐹 ,a transition of the form,
24
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Consider the following pushdown automaton over the input alphabet Σ = {𝑎, 𝑏} and stack
alphabet Γ = {#, 𝐴}.
The number of strings of length 100 accepted by the above pushdown automaton is ______
Answer: 50
Explanation:
In PDA, first understand the meaning of the transitions
initially stack is empty
(𝛜,𝛜 | #) means without seeing (first 𝛜) any input and without seeing top of stack (second 𝛜) then
push # in stack.
(a,𝛜 | A) means push A in the stack for each “a” in the beginning. In this transition “𝛜” means
without seeing top of stack i.e, for any top of stack we must push A.
From q1 to q2
(𝛜,𝛜 | 𝛜) means without seeing (first 𝛜) any input and without seeing top of stack (second 𝛜) then
do nothing (third 𝛜) i.e., just switch state q1 to q2.
The (b, A | 𝛜) means for each “b” in input and A is top of stack pop A.
String 1: a a a a a a a a a a (zero b)
String 2: a a a a a a a a a b (one b)
String 3: a a a a a a a a b b (two b’s)
String 4: a a a a a a a b b b (three b’s)
String 5: a a a a a a b b b b (four b’s)
25
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
𝑆1:Every SLR(1) grammar is unambiguous but there are certain unambiguous grammars that are
not SLR(1).
( 3)
𝑆2: For any context-free grammar, there is a parser that takes at most 𝑂 𝑛
Answer: A
Explanation:
Every unambiguous grammar need not be SLR(1). As we know some unambiguous grammar
which is CLR(1) but not SLR(1). So S1 is true.
Any CFG (which is in CNF form) can be parsed by CYK algorithm in O(n3) where n is length of
string. Although it is not given that CFG is in CNF form but since we can convert any CFG in
CNF form so S2 is true.
27. Consider the relation R(P, Q, S, T, X, Y, Z, W) with the following functional dependencies.
𝑃𝑄 → 𝑋; 𝑃 → 𝑌𝑋; 𝑄 → 𝑌; 𝑌 → 𝑍𝑊
Consider the decomposition of the relation R into the consistent relations according to the
following two decomposition schemes.
26
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Which one of the following options is correct?
Answer : 4
Explanation :
D1:
D2:
27
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Answer: D
Solution:
Variance(X) = Var[X]= E((X-E(X))^2)
28
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
For a dataset with single values, we have variance 0.
2
(𝐸[(𝑋 − 𝐸(𝑋))(𝑌 − 𝐸(𝑌))]) > 𝑉𝑎𝑟[𝑋] 𝑉𝑎𝑟[𝑌]
This leads to inequance of 0>0 which is incorrect.
29. Define 𝑅𝑛to be the maximum amount earned by cutting a rod of length n metres into one or
more pieces of integer length and selling them. For i > 0, let p[i] denote the selling price of a rod
whose length is i meters. Consider the array of prices:
Explanation:
29
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
P[6] + P[1] → 17+1 = 18
P[7] → 18 = 18
___________________________________________________________________________
30. An articulation point in a connected graph is a vertex such that removing the vertex and its
incident edges disconnects the graph into two or more connected components.
Solution: 2 and 4
Explanation:
30
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Statement-4: TRUE: The root of a DFS-tree is an articulation point if and only if it has at least
two children.
31
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Node 2 is an AP because any node from the first subtree (1, 2) is connected to any node from the
second subtree (4, 5, 6, 7, 8) by a path that includes node 2. If node 2 is removed, the 2 subtrees
are disconnected.
_________________________________________________________________
32
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
31. In the context of operating systems, which of the following statements is/are correct with
respect to paging?
Answer : 3,4
Explanation :
(1) False, Large page size may lead to higher internal fragmentation.
(2) False, To support pages of different sizes, the Instruction set architecture should support
it. Multi-level paging is not necessary.
(3) True, The page table has to be stored in main memory, which is an overhead.
(4) True, Paging avoids the external fragmentation.
32. Three processes arrive at time zero with CPU bursts of 16, 20 and 10 milliseconds. If the
scheduler has prior knowledge about the length of the CPU bursts, the minimum achievable
average waiting time for these three processes in a non-preemptive scheduler (rounded to nearest
integer) is _________ milliseconds.
Answer : 12
Explanation :
33. Consider the following instruction sequence where registers R1, R2 and R3 are general
purpose and MEMORY[X] denotes the content at the memory location X.
33
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Assume that the content of the memory location 5000 is 10, and the content of the register R3 is
3000. The content of each of the memory locations from 3000 to 3010 is 50. The instruction
sequence starts from the memory location 1000. All the numbers are in decimal format. Assume
that the memory is byte addressable.
After the execution of the program, the content of memory location 3010 is _______
Ans: 50
Explanation:
Register R1 will get value 10 from location 5000. So the loop in the given program will run for 10
times as the loop condition is based on ‘Dec R1’. When R1 is 0 then the loop terminates.
In these 10 iterations of the loop contents of memory locations 3000 to 3009 are changed as
initial value of R3 is 3000 and in each iteration we update M[R3] ← R2 and the value of R3 is
incremented to the next location 3001, 3002 etc.
But the value in location 3010 is unchanged and it will be the same as the initial value which is
50.
34. Consider the sliding window flow-control protocol operating between a sender and a receiver
over a full-duplex error-free link. Assume the following:
34
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
● The time taken for processing the data frame by the receiver is negligible.
● The time taken for processing the acknowledgement frame by the sender is negligible.
● The sender has an infinite number of frames available for transmission.
● The size of the data frame is 2,000 bits and the size of the acknowledgment frame is 10
bits.
6
● The link data rate in each direction is 1 Mbps (=10 bits per second).
● One way propagation delay of the link is 100 milliseconds.
The minimum value of the sender’s window size in terms of the number of frames, (rounded to
the nearest integer) needed to achieve a link utilization of 50% is ______.
Answer : 51
Explanation :
Tt(packet) = L / B.W => 2000 bits / 10^6 bps = 2 x 10^-3 sec = 2 millisec
Tt(Ack) = L / B.W. => 10 bits / 10^6 bps = 10^-5 sec = 10^-2 millisec = 0.01 millisec
Tp = 100 millisec
Efficiency = 50 % = ½
½ = n x Tt / Total time
35. For a Turing machine M, <M> denotes an encoding of M. Consider the following two
languages.
35
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Which one of the following options is correct?
Answer: 4
Explanation:
L1 is decidable.
We can take all strings of length zero to length 2021.
If TM takes more than 2021 steps on above inputs then definitely it will take more than 2021
steps on all input greater than length 2021.
If TM takes less than 2021 steps:
In such a case suppose TM takes less than 2021 steps (let's say 2020 steps ) for string length
2021, 2022, 2023, then definitely TM will take 2020 steps for all input greater than 2023. Hence
in both cases it is decidable.
Similarly L2 is also decidable. If we can decide for all inputs then we can decide for some inputs
also.
𝑆1:The sequence of procedure calls corresponds to a preorder traversal of the activation tree.
𝑆2:The sequence of procedure returns corresponds to a postorder traversal of the activation tree.
Answer: 2
Explanation: The given statements are true, they are well known facts.
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
36
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
1. The sequence of procedure calls corresponds to a preorder traversal of the
activation tree.
2. The sequence of returns corresponds to a postorder traversal of the
activation tree.
37. Let G be a group of order 6, and H be a subgroup of G such that 1 < |H| < 6.
Answer : 4
Explanation :
38. A relation R is said to be circular of aRb and bRc together imply cRa. Which of the
following options is/are correct?
37
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
3. If a relation S is circular and symmetric, then S is an equivalence relation.
4. If a relation S is reflexive and symmetric, then S is an equivalence relation.
Answer : 1
Explanation :
For symmetry, assume that x, y ∈ A so that xRy, lets check for yRx.
Since R is reflexive and y ∈ A, we know that yRy. Since R is circular and xRy and yRy, we
know that yRx. Thus R is symmetric.
For transitivity, assume that x, y, z ∈ A so that xRy and yRz. Check for xRz. Since R is circular
and xRy and yRz, we know that zRx. Since we already proved that R is symmetric, zRx implies
that xRz. Thus R is transitive.
𝐹 = (𝑋 + 𝑌 + 𝑍)(𝑋 + 𝑌)(𝑌 + 𝑍)
1. (𝑋 + 𝑍)(𝑌 + 𝑍)
2. 𝑋𝑌 + 𝑌𝑍 + 𝑋 𝑌 𝑍
3. 𝑋𝑌 + 𝑍
4. (𝑋 + 𝑌 + 𝑍)(𝑋 + 𝑌)(𝑌 + 𝑍)
Solution: 1,2,3
Explanation:
38
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
= Y’(X+X’Z’) + YZ
= Y’(X+Z’) + Y
= XY’ + (Y’+Y)Z’
= XY’ + Z’.
The expression (X+Z’)(Y’+Z’) is a PoS expression which also represents the same function
(X,Y,Z).
_____________________________________________________________________
40. Consider two hosts P and Q connected through a router R. The maximum transfer unit
(MTU) value of the link between P and R is 1500 bytes, and between R and Q is 820 bytes.
39
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
A TCP segment of size 1400 bytes was transferred from P to Q through R, with IP identification
value as 0x1234. Assume that the IP header size is 20 bytes. Further, the packet is allowed to be
fragmented, i.e., Don’t Fragment (DF) flag in the IP header is not set by P.
1. If the second fragment is lost, R will resend the fragment with the IP identification value
0x1234.
2. If the second fragment is lost, P is required to resend the whole TCP segment.
3. Two fragments are created at R and the IP datagram size carrying the second fragment is
620 bytes.
4. TCP destination port can be determined by analysing only the second fragment.
Answer : 2,3
Explanation :
Answer : 3
40
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Explanation :
Given
|𝐴 − λ𝐼| = 0
4 2
⇒ λ − 6λ − 8λ − 3 = 0
Eigen values, λ = 3, − 1, − 1, − 1
Largest = 3
42. The lifetime of a component of a certain type is a random variable whose probability density
function is exponentially distributed with parameter 2. For a randomly picked component of this
type, the probability that its lifetime exceeds the expected lifetime (rounded to 2 decimal places)
is _______.
Answer : 0.37
Explanation :
Parameter λ = 2
1 1
Mean = λ
= 2
41
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
−λ𝑥
Probability Density Function, PDF = 𝑓(𝑥) = λ · 𝑒
43. Consider the following grammar (that admits a series of declarations, followed by
expressions) and the associated syntax directed translation (SDT) actions, given as pseudo-code:
P ⟶ D* E*
D ⟶ int ID {record that ID.lexeme is of type int}
D ⟶ bool ID {record that ID.lexeme is of type bool}
E ⟶ E1 + E2 {check that E1.type = E2.type = int; set E.type := int}
E ⟶ !E1 {check that E1.type = bool; set E.type := bool}
E ⟶ ID {set E.type := int}
With respect to the above grammar, which one of the following choices is correct?
1. The actions can be used to type-check syntactically correct integer variable declarations
and integer expressions.
2. The actions will lead to an infinite loop.
3. The actions can be used to type-check syntactically correct boolean variable declarations
and boolean expressions.
4. The actions can be used to correctly type-check any syntactically correct program.
Answer: option 4
Explanation: This SDT will never lead to infinite loop so option 2 is false. This SDT is type
checking for bool as well as integer variables, hence this SDT can be used to correctly
type-check any syntactically correct program involving boolean and integer variables.
42
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
44. Suppose a database system crashes again while recovering from a previous crash. Assume
checkpointing is not done by the database either during the transactions or during recovery.
1. The same undo and redo list will be used while recovering again.
2. The database will become inconsistent.
3. The system cannot recover any further.
4. All the transactions that are already undone and redone will not be recovered again.
Answer: 1
Explanation: Suppose a database system crashes again while recovering it from the previous
crash then also we need to make use of the redo and undo list to recover the system.
45. Which of the following standard C library functions will always invoke a system call when
executed from a single-threaded process in a UNIX/linux operating system?
1. sleep
2. strlen
3. malloc
4. exit
Answer : 1,3,4
Explanation :
● A sleep system call takes a time value as a parameter, specifying the minimum amount of
time that the process is to sleep before resuming execution. The parameter typically
specifies seconds, although some operating systems provide finer resolution, such as
milliseconds or microseconds.
43
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
● strlen() is not system call.
● The function call malloc() is a library function call that further uses the brk() or sbrk()
system call for memory allocation
● Exit also system call
Answer : 3
Explanation :
47. Consider the following pseudocode, where S is a semaphore initialized to 5 in line#2 and
counter is a shared variable initialized to 0 in line#1. Assume that the increment operation in
line#7 is not atomic.
1. int counter = 0
2. Semaphore S = init(5);
3. void parop(void)
4. {
44
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
5. wait(S);
6. wait(S);
7. counter++;
8. signal(S);
9. signal(S);
10. }
If five threads execute the function parop concurrently, which of the following program
behaviour(s) is/are possible?
1. The value of counter is 1 after all the threads successfully complete the execution of
parop.
2. The value of counter is 5 after all the threads successfully complete the execution of
parop.
3. The value of counter is 0 after all the threads successfully complete the execution of
parop.
4. There is a deadlock involving all the threads.
Answer : 1,2,4
Explanation :
count =0
S=5
func()
{
wait();
wait();
count++;
signal();
signal();
}
Answer:
45
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
No. of threads = 5
5 ≥ 5* (2-1)+1
≱ 6. So deadlock is possible.
Assembly level:
read R0, count
inc R0, 1
write count, R0
48. Consider the following context-free grammar where the set of terminals is {a, b, c, d, f}.
𝑆 → 𝑑𝑎𝑇 | 𝑅𝑓
𝑇 → 𝑎𝑆 | 𝑏𝑎𝑇 | ϵ
𝑅 → 𝑐𝑎𝑇𝑅 | ϵ
46
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Which one of the following choices represents the correct combination for the numbered cells in
the parsing table (“blank” denotes that the corresponding cell is empty)?
1. ① S ⟶ Rf ② S ⟶ Rf ③T⟶∊ ④T⟶∊
2. ① blank ② S ⟶ Rf ③T⟶∊ ④T⟶∊
3. ① S ⟶ Rf ② blank ③ blank ④T⟶∊
4. ① blank ② S ⟶ Rf ③ blank ④ blank
Answer: Option 1
Explanation:
(1) S-> Rf
(2) S->Rf
(3) T-> 𝛆
(4) T-> 𝛆
47
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Answer: 2
Explanation:
Option A accepts string “01111” which does not end with 011 hence wrong.
Option C accepts string “0111” which does not end with 011 hence wrong.
Option D accepts string “0110” which does not end with 011 hence wrong.
Option B is correct.
The NFA for language in which all strings ends with “011”
48
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
50. A five-stage pipeline has stage delays of 150, 120, 150, 160 and 140 nanoseconds. The
registers that are used between the pipeline stages have a delay of 5 nanoseconds each.
The total time to execute 100 independent instructions on this pipeline, assuming there are no
pipeline stalls, is ______ nanoseconds.
Ans:17160
49
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
32
51. Consider a computer system with a byte-addressable primary memory of size 2 bytes.
10
Assume the computer system has a direct-mapped cache of size 32 KB (1 KB = 2 bytes), and
each cache block is of size 64 bytes.
Ans: 17
Explanation:
Given that the main memory is 2^32 bytes. So the physical address is 32 bits long.
Since it is a direct mapped cache the physical address is divided into fields as (TAG, LINE,
OFFSET).
Number of blocks in the cache = 2^15//2^6 = 2^9, So LINE number needs 9 bits.
52. Let G = (V, E) be an undirected unweighted connected graph. The diameter of G is defined
as:
Define graph 𝐺2on the same set of vertices with adjacency matrix N, where
50
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
3. diam(G) < diam(G2) ≤ 2 diam(G)
4. diam(G2) = diam(G)
Answer : 2
53. Consider the following undirected graph with edge weights as shown:
Answer : 3
Explanation :
(iii) Replace all diagonal zero’s by the degree of the corresponding vertex.
(iv) Co-factors of any element will give the number of spanning trees.
Using the Kirchhoff theorem will take lot of time because the number of vertices are 9.
So, we use brute force technique to solve the problem with the help of Kruskal's algorithm.
51
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
MST-1:
MST-2:
MST-3:
52
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
54. Let <M> denote an encoding of an automaton M. Suppose that Σ = {0,1}. Which of the
following languages is/are NOT recursive?
Answer: 3
Explanation:
L={ <M> | M is a DFA such that L(M)=𝛟 }. M is a DFA so L(M) will be a regular and the
emptiness problem for regular language is decidable.
L={ <M> | M is a DFA such that L(M)=𝚺* }. M is a DFA so L(M) will be a regular and the
completeness problem for regular language is decidable.
L={ <M> | M is a PDA such that L(M)=𝚺* }. M is a PDA so L(M) will be context free language
and the completeness problem for context free language is undecidable.
L={ <M> | M is a PDA such that L(M)=𝛟 }. M is a PDA so L(M) will be context free language and
the emptiness problem for context free language is decidable.
53
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
55. Consider a linear list based directory implementation in a file system. Each directory is a list
of nodes, where each node contains the file name along with the file metadata, such as the list of
pointers to the data blocks.Consider a given directory foo.
Which of the following operations will necessarily require a full scan of foo for successful
completion?
Answer : 3,4
Explanation :
Renaming and creating a new file requires us to search the complete inode for duplicate names
(to check if the same name already exists). There is no such problem in deleting and opening a
file, as duplicate names are not possible while they are created.
Answer : 2
Explanation :
54
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
9 2
Consider the further equation ⇾ 7𝑛 + 7𝑛 ( ) + 7𝑛( )
9
10 10
⎰ 9 2 ⎱ 9 𝑘
+ ( ) +... + ( )
9
= 7𝑛 1 +
⎱ 10 10 ⎰ 10
= 7𝑛( )1
(1−(9/10))
= Θ(𝑛)
Note: The left of the side of the depth is 𝑙𝑜𝑔2𝑛 and right side of the depth is 𝑙𝑜𝑔5/2𝑛.
57. There are 6 jobs with distinct difficulty levels, and 3 computers with distinct processing
speeds. Each job is assigned to a computer such that:
- The fastest computer gets the toughest job and the slowest computer gets the easiest job.
- Every computer gets at least one job.
Answer: 65
Let the levels be 1,2,3,4,5,6. (1 is the least difficult, 6 is the most difficult level)
Let the computers be F,M,S( fast, medium, slow).
55
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
none.
Another constraint is that, every computer must be assigned atleast one.
So compute with assigning one job to M, two jobs to M, three jobs to M and four jobs to M.
Assigning one job to M: we can assign 1 out of 4 jobs in (4C1 ways) and remaining 3 jobs to F,S
in 2*2*2 = 8 ways. (each job has two options, either F or S),
Assigning two jobs to M: we can select two jobs from 4 in 4C2 ways and remaining 2 can be
distributed to F and S in 2*2 ways ( each job has two options either F or S)
Assigning three jobs to M: we can select 3 out of 4 in 4C3 ways remaining can be distributed to
F,M in 2 ways.
= 32+24+8+1
=65
Which algorithm out of the following options uses the least number of comparisons (among the
array elements) to sort the above array in ascending order?
Answer : 2
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
56
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Explanation :
Quick sort(with last element as pivot) → will give the worst case time complexity as O(n^2).
Merge Sort → The merge sort will not depend upon the input order and will give O(nlogn) time
complexity.
Insertion Sort → Insertion sort will perform best case time complexity when the input array is in
sorted order. If the array is already sorted then the inversion count is 0 and If the array is sorted
in reverse order that inversion count is the maximum.
Note: Inversion formal definition is two elements A[i] and A[j] form an inversion if A[i] > A[j] and i
< j.
The number of comparisons will not take more than “n” for the given input array.
Selection Sort → Selection sort will not depend upon the input order and will give O(n^2) time
complexity.
_____________________________________________________________________
# include <stdio.h>
int main()
{
int i, j, count;
count = 0;
i = 0;
for (j = -3; j <= 3; j++)
{
if ((j >= 0) && (i++))
count = count + j;
}
count = count + i;
printf(“%d”, count);
return 0;
}
57
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Which one of the following options is correct?
Solution: B
Explanation:
For(j = -3; j <= 3; j++) → Condition TRUE then enters into the loop.
if((j >= 0) && (i++)) → Condition fails because they are given logical AND.
So, we are not entering the “if” condition and come out of the loop. The count and “i” values
remain “0”.
For(j = -2; j <= 3; j++) → Condition TRUE then enters into the loop.
if((j >= 0) && (i++)) → Condition fails because they are given logical AND.
So, we are not entering the “if” condition and come out of the loop. The count and “i” values
remain “0”.
For(j = -1; j <= 3; j++) → Condition TRUE then enters into the loop.
if((j >= 0) && (i++)) → Condition fails because they are given logical AND.
So, we are not entering the “if” condition and come out of the loop. The count and “i” values
remain “0”.
For(j = 0; j <= 3; j++) → Condition TRUE then enters into the loop.
if((j >= 0) && (i++)) → Condition TRUE then enters into the loop.
count=0+0 → Count=0
58
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
For(j = 1; j <= 3; j++) → Condition TRUE then enters into the loop.
if((j >= 0) && (i++)) → Condition TRUE then enters into the loop.
count=0+1 → Count=1
For(j = 2; j <= 3; j++) → Condition TRUE then enters into the loop.
if((j >= 0) && (i++)) → Condition TRUE then enters into the loop.
count=1+2 → Count=3
For(j = 3; j <= 3; j++) → Condition TRUE then enters into the loop.
if((j >= 0) && (i++)) → Condition TRUE then enters into the loop.
count=3+3 → Count=6
For(j = 4; j <= 3; j++) → Condition FALSE we are not entering the loop.
The above code segment executes successfully and will print value=10.
_______________________________________________________________________
60. A relation r(A, B) in a relational database has 1200 tuples. The attribute A has integer values
ranging from 6 to 20, and the attribute B has integer values ranging from 1 to 20. Assume that
the attributes A and B are independently distributed.
Answer : 820
Explanation :
59
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Probability of 1st condition being satisfied(say P(A)) = 10/15 = 2/3
Probability of 2nd condition being satisfied(say P(B)) = 1/20
Probability of both conditions being satisfied(say P(A intersection B)) = 2/3*1/20 = 1/30
Probability of any one condition being satisfied = P(A union B) = P(A)+P(B)-P(A intersection
B) = 2/3 + 1/20 - 1/30 = 41/60
therefore, expected number of tuples = (41/60)*1200 = 820
61. Suppose that 𝐿1is a regular language and 𝐿2is a context free language. Which one of the
following languages is NOT necessarily context free?
A. L1. L2
B. L1 ∪ L2
C. L1 ∩ L2
D. L1 − L2
Answer: D
Explanation:
L1. L2 => regular . CFL == CFL. CFL (as every regular is CFL so we can assume regular as
CFL)
Since CFL is closed under concatenation so
CFL. CFL= CFL
Hence
Regular . CFL = CFL is true
Please note this is a special property of regular languages so we will not upgrade regular
into CFL (as we did in S1 and S2). We can directly use these closure properties.
60
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Since CFL is not closed under complement so complement of CFL may or may not be CFL
For ex:
R= (a+b+c)* and L= {am bn ck | m ≠ n or n ≠ k} which is CFL.
So
R − L = (a+b+c)* − {am bn ck | m ≠ n or n ≠ k}
62. Assume that a 12-bit Hamming code word consisting of 8-bit data and 4 check bits is
𝑑8𝑑7𝑑6𝑑5𝑐8𝑑4𝑑4𝑑3𝑑2𝑐4𝑑1𝑐2𝑐1, where the data bits and the check bits are given in the following
tables:
Which one of the following choices gives the correct values of x and y?
1. x is 1 and y is 1
2. x is 0 and y is 1
3. x is 1 and y is 0
4. x is 0 and y is 0
Solution: 4
Explanation:
61
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
C2=1, d1= 1, d3= 1, d4= 0, d6= 0, d7= 1.
x=d5=0
C8=y=0.
x=y=0.
Assuming the initial state of the counter given by PQR as 000, what are the next three states?
Solution: 3
62
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
Explanation:
RQP Rn Qn Pn
000 011
011 101
101 000
Therefore, the next three states are : 101, 000 and 011
________________________________________________________________________
64. Let P be an array containing n integers. Let t be the lowest upper bound on the number of
comparisons of the array elements, required to find the minimum and maximum values in an
arbitrary array of n elements. Which one of the following choices is correct?
𝑛
1. 𝑡 > 𝑛 𝑎𝑛𝑑 𝑡 ≤ 3⎡ 2
⎤
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
63
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
𝑛
2. 𝑡 > 3⎡ 2
⎤ 𝑎𝑛𝑑 𝑡 ≤ 2𝑛 − 2
3. 𝑡 > 2𝑛 − 2
4. 𝑡 > ⎡𝑙𝑜𝑔2(𝑛)⎤ 𝑎𝑛𝑑 𝑡 ≤ 𝑛
Answer : 1
Explanation:
Method-1:
MaxMin is a recursive algorithm that finds the maximum and minimum of the set of elements
{a(i), a(i+1), ..., a(j)}. The situation of set sizes one (i=j) and two (i=j-1) are handled separately.
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
64
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
For sets containing more than two elements, the midpoint is determined ( just as in binary
search) and two new subproblems are generated. When the maxima and minima of these
subproblems are determined, the two maxima are compared and the two minima are compared
to achieve the solution for the entire set.
To find the number of element comparisons needed for Maxmin, T(n) represents this number,
then the resulting recurrence relation is
k
When n is a power of two, n = 2 for some positive integer k, then
T(n)=2T(n/2)+2
=2(2T(n/4)+2)+2
=4T(n/4)+4+2
፧
=2k-1T(2)+1ik-12i
=2k-1+2k-2
=3n/2-2
= (3*512)/2 -2
= 768-2
= 766
Method-2:
Find the minimum and maximum independently, using n-1 comparisons for each, for a total of
2n-2 comparisons. In fact, at most 3⌊n/2⌋ comparisons are sufficient to find both the minimum
and the maximum. The strategy is to maintain the minimum and maximum elements seen thus
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
65
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
far. Rather than processing each element of the input by comparing it against the current
minimum and maximum, at a cost of 2 comparisons per element, we process elements in pairs.
We compare pairs of elements from the input first with each other, and then we compare the
smaller to the current minimum and the larger to the current maximum, at a cost of 3
comparisons for every 2 elements.
Setting up initial values for the current minimum and maximum depends on whether n is odd or
even. If n is odd, we set both the minimum and maximum to the value of the first element,and
then we process the rest of the elements in pairs. If n is even, we perform 1 comparison on the
first 2 elements to determine the initial values of the minimum and maximum, and then process
the rest of the elements in pairs as in the case for odd n.
Let us analyze the total number of comparisons. If n is odd, then we perform 3⌊n/2⌋
comparisons. If n is even, we perform 1 initial comparison followed by 3(n-2)/2 comparisons, for
a total of (3n/2)-2. Thus, in either case, the total number of comparisons is at most 3⌊n/2⌋.
= (3*512)/2 -2
= 768-2
= 766
Method-3:
Step-1: To find the minimum element in the array will take n-1 comparisons.
We are given 512 elements. So, to find the minimum element in the array will take
512-1= 511
Step-2: To find the largest element in the array using the tournament method.
1. After the first round of Tournament , there will be exactly n/2 numbers =256 that will
66
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
2. The biggest loser (the largest number) should be among these 256 loosers.To find the
65. A binary search tree T contains n distinct elements. What is the time complexity of picking
an element in T that is smaller than the maximum element in T?
1. Θ(𝑙𝑜𝑔 𝑛)
2. Θ(𝑛 𝑙𝑜𝑔 𝑛)
3. Θ(𝑛)
4. Θ(1)
Answer : 4
Explanation :
The time complexity of searching an element in T that is smaller than the maximum element in T
is O(1) time.
Example:
_____________________________________________________________
67
Use “RRCS” code to get 10% Discount on Unacademy Plus Subscription.
Follow on Unacademy : https://unacademy.com/@ravula
68