0% found this document useful (0 votes)
17 views43 pages

solutions

Uploaded by

daniyatabasum6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views43 pages

solutions

Uploaded by

daniyatabasum6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

Karnataka PGCET 2020 Computer Science and Engineering

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

(B) 60, 1024

(C) 1024, 1024

(D) 240, 1024

Answer: B. 60, 1024

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.

Question 2: There are 5 floating stones on a river. A man wants to cross


the river. He can move either 1 or 2 steps at a time. Find the number of
ways in which he can cross the river.

(A) 11

(B) 12

(C) 13

(D) 14
Answer: D. 14

Solution: This is a classic combinatorial problem that can be solved using


dynamic programming or recursion. For n steps, the number of ways is
given by the Fibonacci sequence. For 5 steps, the number of ways is F(6) =
8 + 5 + 1 = 14.

Question 3: Suppose P is the number of cars per minute passing through


a certain road junction between 5 PM and 6 PM, and P has a Poisson
distribution with mean 3. What is the probability of observing fewer than 3
cars during any given minute in this interval?

(A) 8/(2e^3)

(B) 9/(2e^3)

(C) 17/(2e^3)

(D) 26/(2e^3)

Answer: C. 17/(2e^3)

Solution: The Poisson probability of observing k cars is given by P(k) =


(λ^k * e^(-λ)) / k!. For fewer than 3 cars, we sum the probabilities for k = 0,
1, and 2. P(<3) = P(0) + P(1) + P(2) = (3^0 * e^(-3) / 0!) + (3^1 * e^(-3) / 1!)
+ (3^2 * e^(-3) / 2!) = (1 * e^(-3)) + (3 * e^(-3)) + (9/2 * e^(-3)) = 17/2e^3.

Question 4: Let G be a group with 15 elements. Let L be a subgroup of G.


It is known that L ≠ G and that the size of L is at least 4. The size of L is

(A) 3

(B) 5

(C) 7
(D) 9

Answer: B. 5

Solution: By Lagrange's Theorem, the order of a subgroup must divide the


order of the group. The possible divisors of 15 are 1, 3, 5, and 15. Since L
≠ G and has at least 4 elements, the only valid size for L is 5.

Question 5: Which of the following is true?

(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.

(C) The set of all matrices forms a group under multiplication.

(D) Both (B) and (C) are true.

Answer: 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.

Question 6: Consider the first-order logic sentence φ ≡ ∃s ∃t ∃u ∀v


∀w ∀x ∀y ψ(s, t, u, v, w, x, y) where ψ(s, t, u, v, w, x, y) is a
quantifier-free first-order logic formula using only predicate symbols, and
possibly equality, but no function symbols. Suppose φ has a model with a
universe containing 7 elements. Which one of the following statements is
necessarily true?
(A) There exists at least one model of φ with universe of size less than or
equal to 3.

(B) There exists no model of φ with universe of size less than or equal to 3.

(C) There exists no model of φ with universe size of greater than 7.

(D) Every model of φ has a universe of size equal to 7.

Answer: B. There exists no model of φ with universe of size less than or


equal to 3.

Solution: Since φ has a model with a universe of 7 elements and it is


specified that this is a model, it implies the predicates require a larger
universe, hence a model with 3 elements or fewer is not sufficient.

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:

(A) O(log p + log q)

(B) O(p + q)

(C) O(p log q + q log p)

(D) None

Answer: B. O(p + q)

Solution: Merging two unsorted lists involves comparing each element


once from both lists. Thus, the total number of comparisons is proportional
to the sum of the sizes of the two lists, i.e., O(p + q).

Question 8: In a complete k-ary tree, every internal node has exactly k


children or no child. The number of leaves in such a tree with n internal
nodes is:
(A) n(k - 1) + 1

(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.

Question 9: Let P be a QuickSort Program to sort numbers in ascending


order using the first element as pivot. Let t1 and t2 be the number of
comparisons made by P for the inputs (1, 2, 3, 4, 5) and (4, 1, 5, 3, 2)
respectively. Which one of the following holds?

(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:

(A) cannot have more than 37 nodes

(B) has exactly 37 nodes

(C) has exactly 35 nodes

(D) cannot have more than 35 nodes

Answer: B. has exactly 37 nodes

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.

Question 11: In an unweighted, undirected connected graph, the shortest


path from a node S to every other node is computed most efficiently, in
terms of time complexity by

(A) Dijkstra’s algorithm starting from S

(B) Warshall’s algorithm

(C) Performing a DFS starting from S

(D) Performing a BFS starting from S

Answer: D. Performing a BFS starting from S

Solution: For an unweighted, undirected connected graph, the shortest


path from a node to all other nodes can be found using BFS. BFS explores
all the neighboring nodes at the present depth level before moving on to
nodes at the next depth level, ensuring the shortest path is found.
Question 12: What is the time complexity of the following recursive
function:

int DoSomething (int n)

if (n <= 2)

return 1;

else

return (DoSomething (floor(sqrt(n))) + n);

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)

Solution: The expression (P + Q' + R). (P + Q' + R) is already in its


simplest SOP form, so it remains (P + Q + R).

Question 15: If P, Q, R are Boolean variables, then (P + Q) (P'Q' + PR)


simplifies

A. PQ'

B. PR'

C. PQ' + R
D. PR' + Q

Answer: B. PR'

Solution: Using Boolean algebra, the expression (P + Q) (P'Q' + PR)


simplifies to PR'.

Question 16: The amount of ROM needed to implement a 4 bit multiplier


is:

A. 64 bits

B. 128 bits

C. 1 Kbits

D. 2 Kbits

Answer: B. 128 bits

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.

Question 17: For computer 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

Answer: A. Either S1 or S2

Solution: In a three-address instruction format, the address fields can


specify either a memory operand or a processor register, but not typically
an implied accumulator register.

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?

A. A smaller block size implies better spatial locality

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

D. A smaller block size incurs a lower cache miss penalty

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.

Question 19: Given an arbitrary Non-deterministic Finite Automaton (NFA)


with N states, the maximum number of states in an equivalent minimized
DFA is at least:

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

Solution: To accept all substrings of a string w of length n, the minimum


number of states required in a non-deterministic finite automaton is n.

Question 22: Let S and T be languages over Σ = {a, b} represented by the


regular expressions (a + b)* and (a + b)* respectively. Which of the
following is true?

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

Solution: A finite automaton that accepts strings whose lengths are


divisible by 3 requires 3 states to cycle through lengths of 0, 1, and 2
modulo 3.

Question 24: S -> aSa|bS|ab|ba; The language generated by the above


grammar over the alphabet {a, b} is the set of:

A. All palindromes

B. All odd length palindromes

C. Strings that begin and end with the same symbol

D. All even length 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.

Question 25: Which of the following statement(s) regarding a linker


software is/are true?

I. A function of a linker is to combine several object modules into a single


load module.
II. A function of a linker is to replace absolute references in an object
module by symbolic references to locations in other modules.

A. Only I

B. Only II

C. Both I and II

D. Neither I nor II

Answer: C. Both I and II

Solution: A linker performs both functions: combining object modules and


replacing absolute references with symbolic references.

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?

A. Finite state automata

B. Deterministic pushdown automata

C. Non-Deterministic pushdown automata

D. Turing Machine

Answer: A. Finite state automata

Solution: Lexical analysis in modern computer languages can be


effectively handled by finite state automata, as they are capable of
recognizing regular languages which are sufficient for lexical analysis.
Question 27: The least number of temporary variables required to create a
three-address code in static single assignment form for the expression q + r
/ 3 + s - t * 5 + u * v / w is:

A. 7

B. 8

C. 9

D. 4

Answer: D. 4

Solution: By breaking down the expression into simpler sub-expressions,


the minimum number of temporary variables needed is 4.

Question 28: One of the purposes of using intermediate code in compilers


is to:

A. make parsing and semantic analysis simpler.

B. improve error recovery and error reporting.

C. increase the chances of reusing the machine-independent code


optimizer in other compilers.

D. improve the register allocation.

Answer: C. increase the chances of reusing the machine-independent


code optimizer in other compilers.

Solution: Intermediate code generation abstracts away machine-specific


details, facilitating code optimization and reuse across different compilers.
Question 29: A linker reads four modules whose lengths are 200, 800, 600
and 500 words respectively. If they are loaded in that order, what are the
relocation constants?

A. 0, 200, 500, 600

B. 0, 200, 1000, 1600

C. 200, 500, 600, 800

D. 200, 700, 1300, 2100

Answer: B. 0, 200, 1000, 1600

Solution: The relocation constants are calculated based on the lengths of


the modules and their loading order, resulting in 0, 200, 1000, and 1600.

Question 30: The minimum number of page frames that must be allocated
to a running process in a virtual memory environment is determined by

A. The instruction set architecture

B. Page size

C. Physical memory size

D. Number of processes in memory

Answer: A. The instruction set architecture

Solution: The minimum number of page frames required is influenced by


the instruction set architecture, as it determines the maximum number of
simultaneous memory accesses.

Question 31: In which one of the following page replacement policies,


Belady’s anomaly may occur?
A. Optimal

B. FIFO

C. LRU

D. MRU

Answer: B. FIFO

Solution: Belady’s anomaly, where increasing the number of page frames


results in more page faults, can occur in FIFO page replacement policy.

Question 32: Which of the following is NOT true of deadlock prevention


and deadlock avoidance schemes?

A. In deadlock prevention, request for resources is always granted if the


resulting state is safe.

B. In deadlock avoidance, the request for resources is always granted if the


result state is safe.

C. Deadlock avoidance is less restrictive than deadlock prevention.

D. Deadlock avoidance requires knowledge of resource requirements a


priori.

Answer: A. In deadlock prevention, request for resources is always


granted if the resulting state is safe.

Solution: This statement is false because in deadlock prevention, requests


are not always granted; instead, they are restricted to prevent any
possibility of deadlock.

Question 33: Consider three CPU-intensive processes (process id 0, 1, 2


respectively) which require 10, 20 and 30 time units and arrive at times 0, 2
and 6, respectively. How many context switches are needed if the operating
system uses a shortest remaining time first scheduling algorithm? Do not
count the context switches at time zero and at the end.

A. 1

B. 2

C. 3

D. 4

Answer: C. 3

Solution: Using the shortest remaining time first algorithm, context


switches will occur as each process with the shortest remaining time is
selected. A total of 3 context switches will be needed.

Question 34: Consider three processes (process id 0, 1, 2 respectively)


with compute time bursts 2, 4 and 8 time units. All processes arrive at time
zero. Consider the Longest Remaining Time First (LRTF) scheduling
algorithm. In LRTF, ties are broken by giving priority to the process with the
lowest process id. The average turnaround time is:

A. 13 units

B. 14 units

C. 15 units

D. 16 units

Answer: B. 14 units

Solution: The Longest Remaining Time First algorithm schedules


processes based on the longest remaining burst time. The average
turnaround time for the processes is 14 units.
Question 35: The data blocks of a very large file in the file system are
allocated using

A. contiguous allocation

B. linked allocation

C. indexed allocation

D. an extension of indexed allocation

Answer: C. indexed allocation

Solution: Indexed allocation is used for very large files as it provides


efficient access and management by maintaining an index block that
contains pointers to data blocks.

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?

A. x = 5, not (not (x = 5))

B. x < 5, x >= 5 and x = 6, where x is an integer

C. x < 5, not (x >= 5)

D. None of the above

Answer: A. x = 5, not (not (x = 5))

Solution: In SQL, comparisons involving null values return unknown, so


double negation with null values may not be equivalent.
Question 37: Consider a schema R (A, B, C, D) and functional
dependencies A → B and C → D. Then the decomposition of R into R1(A,
B) and R2(C, D) is

A. dependency preserving and lossless join

B. lossless join but not dependency preserving

C. dependency preserving but not lossless join

D. not dependency preserving and not lossless join

Answer: D. not dependency preserving and not lossless join

Solution: The decomposition does not preserve the original dependencies


and does not guarantee a lossless join.

Question 38: Consider a relational table with a single record for each
registered student with the following attributes.

1. Registration_Number: <Unique registration number for each registered


student>

2. UID: Unique identity number, unique at the national level for each citizen.

3. Bank_Account_Number: Unique account number at the bank. A student


can have multiple accounts or joint accounts. This attribute stores the
primary account number.

4. Name: Name of the student

5. Hostel_Room: Room number of the student

Which of the following options is INCORRECT?

A. BankAccount_Number is a candidate key

B. Registration_Number can be a primary key


C. UID is a candidate key if all students are from the same country

D. If S is a superkey such that S ∩ UID is NULL then S ∪ UID is also a


superkey

Answer: A. BankAccount_Number is a candidate key

Solution: BankAccount_Number cannot be a candidate key because a


student can have multiple accounts or joint accounts, violating the
uniqueness requirement of candidate keys.

Question 39: Consider a relation scheme R = (A, B, C, D, E, H) on which


the following functional dependencies hold: (A -> B, BC -> D, E -> C, D ->
A). What are the candidate keys of R?

A. AE, BE

B. AE, BE, DE

C. AEH, BEH, BCH

D. AEH, BEH, DEH

Answer: D. AEH, BEH, DEH

Solution: To determine the candidate keys, we need to identify which sets


of attributes can determine all other attributes. After examining the
functional dependencies, we find that AEH, BEH, and DEH can determine
all attributes in R, making them the candidate keys.

Question 40: Which of the following concurrency control protocols ensure


both conflict serializability and freedom from deadlock?

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

Solution: 2-phase locking ensures conflict serializability and prevents


deadlock. Time-stamp ordering ensures serializability but not freedom from
deadlock.

Question 41: Which of the following scenarios may lead to an


irrecoverable error in a database system?

A. A transaction writes a data item after it is read by an uncommitted


transaction

B. A transaction reads a data item after it is read by an uncommitted


transaction

C. A transaction reads a data item after it is written by a committed


transaction

D. A transaction reads a data item after it is written by an uncommitted


transaction

Answer: A. A transaction writes a data item after it is read by an


uncommitted transaction

Solution: If a transaction writes a data item after it is read by an


uncommitted transaction, it can lead to an irrecoverable error if the
uncommitted transaction fails.
Question 42: Which of the following is NOT true with respect to a
transparent bridge and a router?

A. Both bridge and router selectively forward data packets

B. A bridge uses IP addresses while a router uses MAC addresses

C. A bridge builds up its routing table by inspecting incoming packets

D. A router can connect between a LAN and a WAN

Answer: B. A bridge uses IP addresses while a router uses MAC


addresses

Solution: A bridge uses MAC addresses to forward data, while a router


uses IP addresses.

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)

Answer: B. p(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. Last fragment, 2400 and 2789

B. First fragment, 2400 and 2759

C. Last fragment, 2400 and 2759

D. Middle fragment, 300 and 689

Answer: C. Last fragment, 2400 and 2759

Solution: HLEN = 10 means header length is 40 bytes. Total length is 400,


so payload length is 360 bytes. Fragment offset is 300 (8-byte units) = 2400
bytes. Thus, first byte is 2400, last byte is 2400 + 360 - 1 = 2759.
Question 46: Suppose that everyone in a group of N people wants to
communicate secretly with the N – 1 others using a symmetric key
cryptographic system. The communication between any two persons
should not be decodable by the others in the group. The number of keys
required in the system as a whole to satisfy the confidentiality requirement
is

A. 2N

B. N(N – 1)/2

C. N(N – 1)

D. (N – 1)^2

Answer: B. N(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

Solution: By Fermat's Little Theorem, a^(p-1) ≡ 1 (mod p) for a prime p


and integer a not divisible by p. Here, 3^16 ≡ 1 (mod 17).
Question 48: How many attributes are there in HTML5?

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.

Question 49: Which of the following statements is/are FALSE?

I. XML overcomes the limitations in HTML to support a structured way of


organizing content.

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

D. III and IV only

Answer: 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

Answer: B. page, flush

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

Question 51: Which of the following statements is true?

(A) The sentence S is a logical consequence of S1,..., Sn if and only if S1


∧ S2 ∧ ... ∧ Sn → S is satisfiable.

(B) The sentence S is a logical consequence of S1,..., Sn if and only if S1


∧ S2 ∧ ... ∧ Sn → S is valid.

(C) The sentence S is a logical consequence of S1,..., Sn if and only if S1


∧ S2 ∧ ... ∧ Sn ∧ S is consistent.

(D) The sentence S is a logical consequence of S1,..., Sn if and only if S1


∧ S2 ∧ ... ∧ Sn ∧ S is inconsistent.
Answer: (B) The sentence S is a logical consequence of S1,..., Sn if and
only if S1 ∧ S2 ∧ ... ∧ Sn → S is valid.

Solution: A sentence S is a logical consequence of premises S1, ..., Sn if


and only if the implication S1 ∧ S2 ∧ ... ∧ Sn → S is logically valid (true
in all interpretations).

Question 52: Let us assume that you construct an ordered tree to


represent the compound proposition (~ (p ∧ q)) ↔ (p ∨ ~q). Then, the
prefix expression and postfix expression determined using this ordered tree
are given as _____ and _____ respectively.

(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 58: Consider the following floating point format


| Signbit | Exponent | Mantissa |
|----|----|----|
| 1 | 8 | 23 |
The decimal number 0.239 * 2^3 has the following hexadecimal
representation (without normalization and rounding off):
A. 0D 24
B. 0D 4D
C. 4D 4D
D. 4D 0D
Answer: A. 0D 24
Solution: The floating-point representation of the given number,
considering the bias and converting to hexadecimal, results in 0D 24.

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.

Question 60: Let L = L1 ∩ L2, where L1 and L2 are languages as defined


below:
L1 = {a^n b^n | n ≥ 0}
L2 = {a^i b^j c^k | i, j, k ≥ 0}
Then L is:
A. Not recursive
B. Regular
C. Context free but not regular
D. Recursively enumerable but not recursive
Answer: A. Not recursive
Solution: The intersection of L1 and L2 results in a language that cannot
be recognized by a Turing machine, hence it is not recursive.

Question 61: Consider the language L1, L2, L3 as given below:


L1: {0^n 1^n | n, q ∈ N}
L2: {0^n 1^n pq, e ∈ N and p = q}
L3: {0^n 1^n pq | e = p q, q = r}
Which of the following statements is NOT TRUE?
A. Push Down Automata (PDA) can be used to recognize L1 and L2
B. L3 is not a regular language
C. Turing machine can be used to recognize all the three languages
D. All the three languages are context-free
Answer: D. All the three languages are context-free
Solution: While L1 and L2 are context-free, L3's additional constraints
make it not context-free.

Question 62: Consider the intermediate code given below:

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

9. if j <= 5 goto (3)

10. i = i + 1

11. if i <= 5 goto (2)

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.

Question 63: A canonical set of items is given below:

S -> L · R

Q -> · R

On input symbol < the set has.


A. a shift-reduce conflict and a reduce-reduce conflict.

B. a shift-reduce conflict but not a reduce-reduce conflict.

C. a reduce-reduce conflict but not a shift-reduce conflict.

D. neither a shift-reduce nor a reduce-reduce conflict.

Answer: B. a shift-reduce conflict but not a reduce-reduce conflict.

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.

Question 64: Consider the grammar

E -> E + n | E × n | n

For a sentence n + n × n, the handles in the right-sentential form of the


reduction are:

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:

Process Execution Time Arrival Time

1 20 0

2 25 15

3 15 35

What is the total waiting time for process P2?

A. 5

B. 15

C. 40

D. 55

Answer: C. 40

Solution: Process P2 arrives at time 15. Process P1 is executing at that


time and completes at time 20. Then P2 starts execution but is preempted
by P3 at time 35. P2 resumes after P3 completes at time 50. Hence, the
total waiting time for P2 is (50 - 15) - 25 = 10 + 30 = 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%.

Question 67: The atomic fetch-and-set x, y instruction unconditionally sets


the memory location x to 1 and fetches the old value of x in y without
allowing any intervening access to the memory location x. Consider the
following implementation of P and V functions on a binary semaphore.

void P (binary_semaphore *s) {

unsigned y;

unsigned *x = &(s -> value);

do {

fetch-and-set x, y;

} while (y);

}
void V (binary_semaphore *s) {

s -> value = 0;

(A) The implementation may not work if context switching is disabled in P.

(B) Instead of using fetch-and-set, a pair of normal load/store can be used.

(C) The implementation of V is wrong.

(D) The code does not implement a binary semaphore.

Answer: A. The implementation may not work if context switching is


disabled in P.

Solution: The implementation relies on the atomicity provided by the


fetch-and-set instruction. If context switching is disabled, it would prevent
other processes from accessing the semaphore, leading to potential
deadlock or starvation scenarios.

Question 68: In a packet switching network, packets are routed from


source to destination along a single path having two intermediate nodes. If
the message size is 24 bytes and each packet contains a header of 3
bytes, then the optimum packet size is:

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.

Question 69: Consider the following tables T1 and T2:

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

Solution: Deleting record (3,8) from table T2 involves cascading deletions


in T1 due to the foreign key constraints. Only one record in T1 is affected
and needs to be deleted.

Question 70: Let R1 (a, b, c) and R2 (x, y, z) be two relations in which x is


the foreign key of R1 that refers to the primary key of R2. Consider the
following operations:

(1) Insert into R1

(2) Insert into R2

(3) Delete from R1

(4) Delete from R2

Which of the following is correct about the referential integrity constraint


with respect to above?

A. Operations (1) and (2) will cause violation.

B. Operations (1) and (4) will cause violation.

C. Operations (3) and (4) will cause violation.

D. Operations (4) and (1) will cause violation.

Answer: C. Operations (3) and (4) will cause violation.


Solution: Inserting into R1 without a corresponding record in R2 (violation
of foreign key

Question 71: Consider the following statements regarding relational


database model:

(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.

One can determine that:

A. (a) and (b) are true.

B. (a) and (c) are true.

C. (b) and (c) are true.

D. (a), (b) and (c) are true.

Answer: B. (a) and (c) are true.

Solution: Statement (a) is true because NULL can be used to avoid


enforcing a foreign key constraint. Statement (b) is false because even if a
table is in 3NF, it is not necessarily in BCNF unless every determinant is a
candidate key. Statement (c) is true because the project operator in
relational algebra eliminates duplicate tuples while SQL SELECT does not.
Question 72: An Internet Service Provider (ISP) has the following chunk of
CIDR-based IP addresses available with it: 245.248.128.0/20. The ISP
wants to give half of this chunk of addresses to Organization A, and a
quarter to Organization B, while retaining the remaining with itself.

Which of the following is a valid allocation of addresses to A and B?

A. 245.248.136.0/21 and 245.248.128.0/22

B. 245.248.128.0/21 and 245.248.128.0/22

C. 245.248.132.0/22 and 245.248.132.0/21

D. 245.248.136.0/22 and 245.248.132.0/21

Answer: B. 245.248.128.0/21 and 245.248.128.0/22

Solution: The given IP block is 245.248.128.0/20, which contains 4096


addresses. Dividing this into halves and quarters, we get:

- Half (2048 addresses): 245.248.128.0/21

- Quarter (1024 addresses): 245.248.128.0/22

This allocation ensures correct partitioning of the given address block.

Question 73: The message 110010001 is to be transmitted using the CRC


polynomial x^3 + 1 to protect it from errors. The message that should be
transmitted is:

A. 1100101000

B. 11001001011

C. 110010010

D. 11001001001
Answer: D. 11001001001

Solution: To generate the CRC, we divide the message polynomial by the


generator polynomial (x^3 + 1). The message is 110010001, and the
generator polynomial is 1011. The CRC bits are obtained by performing
binary division, and the resulting transmitted message is 11001001001.

Question 74: A graphical HTML browser resident at a network client


machine Q accesses a static HTML webpage from a HTTP server S. The
static HTML page has exactly one static embedded image which is also at
S. Assuming no caching, which one of the following is correct about the
HTML webpage loading?

A. Q needs to send at least 2 HTTP requests to S, each necessarily in a


separate TCP connection to server S.

B. A single HTTP request from Q to S is sufficient, and a single TCP


connection between Q and S is necessary for this.

C. Q needs to send at least 2 HTTP requests to S, but a single TCP


connection to server S is sufficient.

D. A single HTTP request from Q to S is sufficient, and this is possible


without any TCP connection between Q and S.

Answer: C. Q needs to send at least 2 HTTP requests to S, but a single


TCP connection to server S is sufficient.

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.

Question 75: Consider the following statements:

I. telnet, ftp and http are application layer protocols.

II. EJB (Enterprise Java Beans) components can be deployed in a J2EE


application server.
III. If two languages conform to the Common Language Specification (CLS)
of the Microsoft .NET framework, then a class defined in any one of them
may be inherited in the other.

Which statements are true?

A. I and II only

B. II and III only

C. I and III only

D. I, II and III

Answer: D. I, II and III

Solution: All three statements are correct. Telnet, FTP, and HTTP are
indeed application layer protocols.

You might also like