solutions
solutions
A-1 - Solutions
PART - 1
Question 1: How many words can be made from the word "APPLE" using
all the alphabets with repetition and without repetition respectively?
(A) 7024, 60
Solution: For words made with repetition, we have 6 possible choices for
each of the 4 remaining positions after the first letter is chosen. Therefore,
the number of words with repetition is 6^5 = 7776. For words made without
repetition, we have 5! (factorial) possible arrangements of the letters. So,
the number of words without repetition is 5! = 120.
(A) 11
(B) 12
(C) 13
(D) 14
Answer: D. 14
(A) 8/(2e^3)
(B) 9/(2e^3)
(C) 17/(2e^3)
(D) 26/(2e^3)
Answer: C. 17/(2e^3)
(A) 3
(B) 5
(C) 7
(D) 9
Answer: B. 5
(A) The set of all rational negative numbers forms a group under
multiplication.
(B) The set of all non-singular matrices forms a group under multiplication.
Solution: The set of all rational negative numbers does not form a group
under multiplication as it lacks an identity element. The set of all
non-singular (invertible) matrices forms a group under multiplication
because it satisfies closure, associativity, the existence of an identity
element, and the existence of inverses.
(B) There exists no model of φ with universe of size less than or equal to 3.
Question 7: For merging two unsorted lists of size p and q into sorted list
of size (p + q). The time complexity in terms of number of comparisons is:
(B) O(p + q)
(D) None
Answer: B. O(p + q)
(B) (n - 1)(k + 1)
(C) n(k - 1) + 1
(D) n(k - 1)
Answer: A. n(k - 1) + 1
Solution: In a complete k-ary tree with n internal nodes, each internal node
has exactly k children, so the total number of children is nk. Since each leaf
is a child but not an internal node, the number of leaves is the total number
of nodes minus the internal nodes, which is nk - n + 1 = n(k - 1) + 1.
(A) t1 = t5
(B) t1 < t2
(C) t1 > t2
(D) t1 = t2
Answer: B. t1 < t2
Solution: In the input (1, 2, 3, 4, 5), the list is already sorted, so the
number of comparisons is minimized. In the input (4, 1, 5, 3, 2), the list is
not sorted, and more comparisons are needed to sort it using QuickSort.
Therefore, t1 < t2.
Question 10: A binary search tree in which every non-leaf node has
non-empty left and right subtrees is called a strictly binary tree. Such a tree
with 19 leaves:
Solution: In a strictly binary tree, the number of internal nodes is one less
than the number of leaves. For 19 leaves, the number of internal nodes is
18. Therefore, the total number of nodes is 19 + 18 = 37.
if (n <= 2)
return 1;
else
A. Θ(n)
B. Θ(nlogn)
C. Θ(logn)
D. Θ(log(logn))
Answer: D. Θ(log(logn))
Solution: The function DoSomething recursively calls itself with the square
root of n. The depth of recursion is determined by how many times you can
take the square root of n until it becomes a small constant. This leads to
the time complexity of Θ(log(logn)).
Question 13: What is the Boolean expression for the output f of the
combinational logic circuit of NOR gates given below.
A. (Q + R)'
B. (P + Q)'
C. (P + Q)'
D. (P + Q + R)'
Answer: C. (P + Q)'
Solution: The given circuit is a combination of NOR gates, and the output f
can be simplified to the NOR of the inputs P and Q, which is expressed as
(P + Q)'.
Question 14: The simplified SOP (Sum Of Product) form of the Boolean
expression (P + Q' + R). (P + Q' + R) is
A. (P + Q' + R)'
B. (P + Q + R)'
C. (P' + Q + R)
D. (P + Q + R)
Answer: D. (P + Q + R)
A. PQ'
B. PR'
C. PQ' + R
D. PR' + Q
Answer: B. PR'
A. 64 bits
B. 128 bits
C. 1 Kbits
D. 2 Kbits
Solution: A 4-bit multiplier would require a ROM size of 2^4 * 2^4 = 256
words, with each word having 4 bits, totaling 256 * 4 = 1024 bits, which is
approximately 128 bytes or bits depending on the context given.
A. Either S1 or S2
B. Either S2 or S3
C. Only S2 and S3
Answer: A. Either S1 or S2
Question 18: In designing a computer’s cache system, the cache block (or
cache line) size is an important parameter. Which one of the following
statements is correct in this context?
B. A smaller block size implies a smaller cache tag and hence lower cache
tag overhead
C. A smaller block size implies a larger cache tag and hence lower cache
hit time
Answer: B. A smaller block size implies a smaller cache tag and hence
lower cache tag overhead
Solution: Smaller block sizes reduce the tag size, leading to lower
overhead in the cache.
A. N
B. 2N
C. N^2
D. N!
Answer: B. 2N
Solution: The equivalent DFA for a given NFA can have at most 2^N states
in the worst case.
Question 20: Given the language L = {ab, aa, baa}, which of the following
strings are in L^2?
1. abaabaaabaa
2. aaaaaaaa
3. baabaaab
4. baaaaaaab
A. 1, 2 and 3
B. 2, 3 and 4
C. 1, 2 and 4
D. 1, 3 and 4
Answer: C. 1, 2 and 4
Solution: The strings in L^2 are formed by concatenating two strings from
L. Hence, the strings 1, 2, and 4 are valid concatenations.
Question 21: Let w be any string of length n in {0,1}*. Let L be the set of all
substrings of w. What is the minimum number of states in a
non-deterministic finite automaton that accepts L?
A. n - 1
B. n
C. n + 1
D. 2n - 1
Answer: B. n
A. S ⊆ T (S is a subset of T)
B. T ⊆ S (T is a subset of S)
C. S = T
D. S ∩ T = ∅
Answer: C. S = T
Solution: Both S and T represent the same language, which includes all
possible strings over the alphabet {a, b}.
Question 23: The smallest finite automation which accepts the language {x
| length of x is divisible by 3} has:
A. 2 states
B. 3 states
C. 4 states
D. 5 states
Answer: B. 3 states
A. All palindromes
Answer: C. Strings that begin and end with the same symbol
Solution: The grammar generates strings that start and end with the same
symbol but not necessarily palindromes.
A. Only I
B. Only II
C. Both I and II
D. Neither I nor II
Question 26: The lexical analysis for a modern computer language such
as Java needs the power of which one of the following machine models in a
necessary and sufficient sense?
D. Turing Machine
A. 7
B. 8
C. 9
D. 4
Answer: D. 4
Question 30: The minimum number of page frames that must be allocated
to a running process in a virtual memory environment is determined by
B. Page size
B. FIFO
C. LRU
D. MRU
Answer: B. FIFO
A. 1
B. 2
C. 3
D. 4
Answer: C. 3
A. 13 units
B. 14 units
C. 15 units
D. 16 units
Answer: B. 14 units
A. contiguous allocation
B. linked allocation
C. indexed allocation
Question 36: In SQL, relations can contain null values, and comparisons
with null values are treated as unknown. Suppose all comparisons with a
null value are treated as false. Which of the following pairs is not
equivalent?
Question 38: Consider a relational table with a single record for each
registered student with the following attributes.
2. UID: Unique identity number, unique at the national level for each citizen.
A. AE, BE
B. AE, BE, DE
I. 2-phase locking.
II. Time-stamp ordering.
A. I only
B. II only
C. Both I and II
D. Neither I nor II
Answer: A. I only
Question 43: Determine the maximum length of the cable (in km) for
transmitting data at a rate of 500 Mbps in an Ethernet LAN with frames of
size 10,000 bits. Assume the signal speed in the cable to be 2,00,000 km/s.
A. 1
B. 2
C. 2.5
D. 5
Answer: B. 2
Solution: The time to transmit one frame is (10,000 bits / 500 Mbps) = 20
microseconds. The maximum length of the cable is (20 microseconds *
2,00,000 km/s) = 4 km round trip, so 2 km one way.
Question 44: There are n stations in a slotted LAN. Each station attempts
to transmit with a probability p in each time slot. What is the probability that
only one station transmits in a given time slot?
A. (1 – p)^(n-1)
B. p(1 – p)^(n-1)
C. np(1 – p)^(n-1)
D. 1 – (1 – p)^(n-1)
Solution: The probability that one specific station transmits and others do
not is p(1 – p)^(n-1). There are n such stations, so the probability is n * p(1
– p)^(n-1).
Question 45: In an IPv4 datagram, the M bit is 0, the value of HLEN is 10,
the value of total length is 400 and the fragment offset value is 300. The
position of the datagram, the sequence numbers of the first and the last
bytes of the payload, respectively are
A. 2N
B. N(N – 1)/2
C. N(N – 1)
D. (N – 1)^2
Solution: For a group of N people, each pair needs a unique key. The
number of such pairs is given by the combination formula C(N, 2) = N(N –
1)/2.
Question 47: The minimum positive integer p such that 3^p modulo 17 = 1
is
A. 5
B. 8
C. 12
D. 16
Answer: D. 16
A. 2
B. 4
C. 1
D. 5
Answer: B. 4
Solution: HTML5 introduced new global attributes, but the most commonly
recognized are 4: charset, contenteditable, contextmenu, and draggable.
II. XML specification is not case sensitive while HTML specification is case
sensitive.
III. XML supports user defined tags while HTML uses pre-defined tags.
IV. XML tags need not be closed while HTML tags must be closed.
A. I only
B. II only
C. II and IV only
Solution: XML is case sensitive, and XML tags must be closed, unlike
HTML which has some optional closing tags.
Question 50: Which of the following attributes are used in <jsp:include>
tag?
A. id, type
B. page, flush
C. type, class
D. type, page
Solution: The <jsp:include> tag uses the 'page' attribute to specify the
resource to include and 'flush' to determine if the buffer should be flushed
before including the resource.
PART - 2
(A) ↔ ~ ∧ p q ∨ p ~ q, pq ∧ ~ pq ∨ ~ ↔
(B) ↔ ~ ∧ pq ∨ p ~ q, pq ∧ ~ pq ∨ ~ ↔
(C) ↔ ~ ∧ p q ∨ p ~ q, pq ∧ ~ pq ∨ ~ ↔
(D) ↔ ~ ∧ pq ∨ p ~ q, pq ∧ ~ pq ∨ ~ ↔
Answer: (C) ↔ ~ ∧ p q ∨ p ~ q, pq ∧ ~ pq ∨ ~ ↔
Solution: The prefix and postfix expressions for the given compound
proposition can be derived by traversing the ordered tree in pre-order and
post-order respectively.
Question 53: In a room there are only two types of people, namely Type 1
and Type 2. Type 1 people always tell the truth and Type 2 people always
lie. You give a fair coin to a person in that room, without knowing which
type he is from and tell him to toss it and hide the result from you till you
ask for it. Upon asking, the person replies the following: "The result of the
toss is head if and only if I am telling the truth". Options: A) The result is
head B) The result is tail C) If the person is of Type 2, then the result is tail
D) If the person is of Type 1, then the result is tail Answer: A) The result is
head Solution: For Type 1 (truth-tellers), the statement "The result of the
toss is head if and only if I am telling the truth" means the result is head.
For Type 2 (liars), if the result were tail, the person would lie and say head.
Hence, the only consistent interpretation is that the result is head.
Question 54: For 8 keys and 6 slots in a hashing table with uniform
hashing and chaining, what is the expected number of items that hash to a
particular location?
A. 2.33
B. 0.75
C. 1.33
D. 2
Answer: A. 2.33
Solution: The expected number of items in each slot is given by the load
factor, which is the number of keys divided by the number of slots. Here,
the load factor is 8 keys / 6 slots = 1.33. Therefore, the expected number of
items that hash to a particular location is 1.33.
Question 55: For a graph with 'E' edges and 'V' vertices, what is the time
complexity of Dijkstra's algorithm using an array as a data structure for
storing non-finalized vertices? The graph is undirected and represented as
an adjacency list.
A. O(VE)
B. O(E log V)
C. O(V^2)
D. O(E^2 log V)
Answer: C. O(V^2)
Solution: When Dijkstra's algorithm is implemented using an array to store
non-finalized vertices, the time complexity is O(V^2) due to the need to
search through the array to find the vertex with the minimum distance.
Question 56: Four matrices M1, M2, M3, and M4 of dimensions p×q, q×r,
r×s, and s×t respectively can be multiplied in several ways with different
numbers of total scalar multiplications. For example, when multiplied as
((M1 × M2) × (M3 × M4)), the total number of multiplications is pqr + rst +
prt. When multiplied as ((M1 × M2) × M3) × M4), the total number of scalar
multiplications needed is:
A. 19000
B. 44000
C. 248000
D. 25000
Answer: B. 44000
Solution: Given p = 10, q = 100, r = 20, s = 5, and t = 80. For ((M1 × M2) ×
(M3 × M4)), the number of multiplications is (10 * 100 * 20) + (20 * 5 * 80) +
(10 * 20 * 80) = 20000 + 8000 + 16000 = 44000.
Question 57: What is the minimal form of the Karnaugh map shown
below? Assume that X denotes a don't care term.
| AB\CD | 00 | 01 | 11 | 10 |
|-----|----|----|----|----|
| 0 | 1 | X | 1 | 1 |
| 1 | X | 1 | 1 | 0 |
A. b'd'
B. b'd + a'b'c'd'
C. b'd' + b'c' + c'd'
D. b'd' + a'b'c'd + cd'
Answer: D. b'd' + a'b'c'd + cd'
Solution: The Karnaugh map simplifies to b'd' + a'b'c'd + cd' when
considering the don't care terms (X) and combining the minterms
appropriately.
Question 59: Consider an instruction pipeline with five stages without any
branch prediction: Fetch Instruction (FI), Decode Instruction (DI), Fetch
Operand (FO), Execute Instruction (EI), and Write Operand (WO). The
stage delays for FI, DI, FO, EI, and WO are 5 ns, 7 ns, 10 ns, 8 ns, and 6
ns, respectively. There are intermediate storage buffers with 1 ns delay
between each stage. The instruction set consists of 12 instructions i1, i2, i3,
..., i12 executed in this pipelined processor. Instruction i4 is the only branch
instruction and its branch target is i9. If the branch is taken during the
execution of this program, the time required to complete the program is:
A. 96
B. 106
C. 176
D. 328
Answer: C. 176
Solution: The time required is calculated considering the delays of each
stage, the intermediate storage buffers, and the branch taken.
1. i = 1
2. j = 1
3. t1 = 5 * i
4. t2 = t1 + j
5. t3 = 4 * t2
6. t4 = t3
7. a[t4] = 1
8. j = j + 1
10. i = i + 1
The number of nodes and edges in the control-flow graph constructed for
the above code, respectively, are
A. 5 and 7
B. 6 and 7
C. 5 and 5
D. 7 and 8
Answer: D. 7 and 8
Solution: The control-flow graph (CFG) for the given code involves nodes
representing the instructions and edges representing the control flow. Each
of the 11 instructions corresponds to a node. The two conditional
statements add edges to the graph. Analyzing the CFG, we have 7 nodes
and 8 edges.
S -> L · R
Q -> · R
Solution: A shift-reduce conflict occurs when the parser can either shift the
next input symbol or reduce a production. In this case, the parser can shift
the '<' symbol or reduce the production L -> · R, leading to a shift-reduce
conflict. There is no reduce-reduce conflict as no two reductions are
possible simultaneously.
E -> E + n | E × n | n
A. n, E + n and E + n × n
B. n, E + n and E + E × n
C. n, n + n and n + n × n
D. n, E + n and E × n
Answer: D. n, E + n and E × n
Solution: In the given grammar, the handle is the part of the sentential
form that matches the right side of a production rule. For the sentence n + n
× n, the handles are n (which reduces to E), E + n (which reduces to E),
and E × n (which also reduces to E).
Question 65: An operating system uses Shortest Remaining Time first
(SRT) process scheduling algorithm. Consider the arrival times and
execution times for the following processes:
1 20 0
2 25 15
3 15 35
A. 5
B. 15
C. 40
D. 55
Answer: C. 40
Question 66: Consider three processes, all arriving at time zero, with total
execution time of 10, 20, and 30 units, respectively. Each process spends
the first 20% of execution time doing I/O, the next 70% of time doing
computation, and the last 10% of time doing I/O again. The operating
system uses a shortest remaining compute time first scheduling algorithm
and schedules a new process when either the running process blocks on
I/O or when the running process finishes its compute burst. Assume that all
I/O operations can be overlapped as much as possible. For what
percentage of time does the CPU remain idle?
A. 0%
B. 10.6%
C. 30.0%
D. 89.4%
Answer: B. 10.6%
Solution: Each process spends 20% of its execution time in I/O initially.
After that, the CPU is busy with the computation phase of the processes.
Considering overlapping I/O operations and scheduling, the CPU remains
idle during the initial I/O phase of the first process. Calculation reveals the
idle percentage to be 10.6%.
unsigned y;
do {
fetch-and-set x, y;
} while (y);
}
void V (binary_semaphore *s) {
s -> value = 0;
A. 9
B. 7
C. 6
D. 4
Answer: B. 7
Solution: To minimize the total number of packets sent, the packet size
should be chosen to maximize the data portion while minimizing the
overhead from headers. With a message size of 24 bytes and each packet
having a 3-byte header, the optimal packet size is calculated as 7 bytes.
T1
P Q
2 2
2 3
4 5
8 8
T2
R S
5 3
7 2
9 2
In table T1, P is the primary key, Q is the foreign key referencing R in table
T2 with on-delete cascade and on-update cascade. In table T2, R is the
primary key and S is the foreign key referencing P in the table T1 with
on-delete set NULL and on-update cascade. In order to delete record (3,8)
from table, numbers of additional record that need to be deleted from table
T1 is
A. 0
B. 1
C. 2
D. 3
Answer: B. 1
(a) NULL values can be used to opt a tuple out of enforcement of a foreign
key.
(b) Suppose that table T has only one candidate key. If Q is in 3NF, then it
is also in BCNF.
(c) The difference between the project operator (π) in relational algebra and
the SELECT keyword in SQL is that if the resulting table/set has more than
one occurrences of the same tuple, then π will return only one of them,
while SQL SELECT will return all.
A. 1100101000
B. 11001001011
C. 110010010
D. 11001001001
Answer: D. 11001001001
Solution: To load the HTML page and the embedded image, at least two
HTTP requests are required. However, both requests can be sent over a
single TCP connection if keep-alive is enabled, making option (C) correct.
A. I and II only
D. I, II and III
Solution: All three statements are correct. Telnet, FTP, and HTTP are
indeed application layer protocols.