MCQs
The following figure represents access graphs of two modules M1 and M2. The filled circles
represent methods and the unfilled circles represent attributes. IF method m is moved to
module M2 keeping the attributes where they are, what can we say about the average
cohesion and coupling between modules in the system of two modules?
Coupling = `( number of external links) / (number of modules )` =`2/2`
Cohesion of a module = `(number of internal links) / ( number of methods)`
Cohesion of `M_1` = `8/4`; Cohesion of `M_2` = `6/3`; Average cohesion=2
After moving method m to M2, graph will become
Coupling = `2/2`
Cohesion of `M_1` = `6/3` Cohesion of `M_2` = `8/4` Average cohesion=2
`:.` answer is no change
Consider the following two sets of LR(1) items of an LR(1) grammar
X `rightarrow` c.X, c / d X `rightarrow` c.X, $
X `rightarrow` .cX, c / d X `rightarrow` .cX, $
X `rightarrow` .d, c / d X `rightarrow` .d, $
Which of the following statements related to merging of the two sets in the corresponding
LALR parser is/are `FALSE`?
1. Cannot be merged since look aheads are different
2. Can be merged but will result in S - R conflict
3. Can be merged but will result in R - R conflict
4. Cannot be merged since goto on c will lead to two different sets
X `rightarrow` c.X, c / d X `rightarrow` c.X, $
X `rightarrow` .cX, c / d X `rightarrow` .cX, $
X `rightarrow` .d, c / d X `rightarrow` .d, $
X `rightarrow` c.X, c / d / $
X `rightarrow` .cX, c / d / $
X `rightarrow` .d, c / d / $
1. Merging of two states depends on core part (production rule with dot operator), not on
look aheads.
2. The two states are not containing Reduce item ,So after merging, the merged state can
not
contain any S - R conflict
3. As there is no Reduce item in any of the state, so can’t have R-R conflict.
4. Merging of stats does not depend on further goto on any terminal.
So all statement
are false.
There is an algorithm to check whether the given CFG is empty, finite or infinite and also to
convert
NFA to DFA hence 1 and 4 are decidable
A certain computation generates two arrays a and b such that a [i] = f (i) for 0 `le` i < n and
b [i] = g (a[i]) for 0 `le` i < n . Suppose this computation is decomposed into two concurrent
processes X and Y such that X computes the array a and Y computes the array b. The
processes
employ two binary semaphores R and S, both initialized to zero. The array a is
shared by the
two processes. The structures of the processes are shown below.
Pr ocess X; Pr ocess Y;
private i; private i;
for (i = 0; i < n; i + + for (i = 0; i < n; i + + {
a[i] = f (i); Entry Y (R, S);
Exit X (R,S); b[i] = g (a[i]);
Which one of the following represents the `CORRECT` implementations of ExitX and
EntryY?
For computing both the array a[ ] and b[ ], first element a[i] should be computed using
which
b[i] can be computed. So process X and Y should run in strict alteration manner,
starting with
X. This requirement meets with implementation of ExitX and EntryY given
in option C.
Preorder :30,20,10,15,25,23,39,35,42
Inorder :10,15,20,23,25,30,35,39,42
30
BST:
20 39
10 25 35 42
15 23
Consider the following operation along with Enqueue and Dequeue operations on queues,
where
k is a global parameter
MultiDequeue Q {
m = k
while (Q is not empty) and (m>o) {
Dequeue (Q)
m = m - 1
}
}
What is the worst case time complexity of a sequence of n queue operations on an initially
empty queue?
Initially the queue is empty and we have to perform n operations.
i) One option is to perform all Enqueue operations i.e. n Enqueue operations. Complexity
will be `theta` (n)
or
ii) We can perform a mix of Enqueue and Dequeue operations. It can be Enqueue for first
n/2 times and then Dequeue for next n/2, or Enqueue and Dequeue alternately, or any
permutation of Enqueues and Dequeues totaling 'n'times. Complexity will be`theta`(n)
or
iii) We can perform Enqueues and MultiDequeues. A general pattern could be as follows:
Enqueue Enqueue ---- (ktimes) MultiDequeue Enqueue Enqueue ---- (ktimes) MultiDequeue
---- Up to total n
---- k items enqueued -----k items deleted----k items enqueued----k items deleted -- and
so on
The number of times this k-Enqueues, MutiDequeue cycle is performed = n/k + 1
So, Complexity will be k times Enqueue + 1 MultiDequeue) x n/k + 1
Which is `theta`(2k x n/k + 1) = `theta` (n)
iv) We can just perform n MultiDequeues (or n Dequeues for that matter):
Each time the while condition is false (empty queue), condition is checked just once for
each of the 'n' operations. So `theta`(n).
RAM chip size = 1k x 8 [1024 words of 8 bits each ]
RAM to construct = 16k x 16
Number of chips required = `(16k xx 16)/(1k xx 8)` = 16 x 2 [16 chips vertically with each having 2 chips horizontally]
So to select one chip out of 16 vertical chips, we need 4 x 16 decoder.
Available decoder is - 2 x 4 decoder
To be constructed is 4 x 16 decoder
EN Q3 D15
Q2 D14
S1 S1 Q1 D13
S0 S0 Q0 D12
EN Q3 D11
1 EN Q3 Q2 D10
Q2 S1 S1 Q1 D9
S3 S1 Q1 S0 S0 Q0 D8
S2 S0 Q0
EN Q3 D7
Q2 D6
S1 S1 Q1 D5
S0 S0 Q0 D4
EN Q3 D3
Q2 D2
S1 S1 Q1 D1
S0 S0 Q0 D0
So we need 5, 2 x 4 decoder in total to construct 4 x 16 decoder.
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 after
each stage and the delay of
each buffer is 1 ns. A program consisting of 12 instructions
`I_1`, `I_2`, `I_3`,......`I_12` is executed in this
pipelined processor. Instruction `I_4` is the only
branch instruction and its branch target is `I_9`. If
the branch is taken during the execution
of this program, the time (in ns) needed to complete
the program is
Clock period=Maximum stage delay + overhead (Buffer) =10 + 1 = 11 ns
Assume FI - 1, DI - 2, FO - 3, EI - 4, WO - 5
`I_1` : 1 2 3 4 5
`I_2` : - 1 2 3 4 5
`I_3` : - - 1 2 3 4 5
`I_4` : - - - 1 2 3 4 5
`I_5` : - - - - 1 2 3 4 5
`I_6` : - - - - - 1 2 3 4 5
`I_7` : - - - - - - 1 2 3 4 5
`I_8` : - - - - - - - 1 2 3 4 5
`I_9` : - - - - - - - - 1 2 3 4 5
`I_10` : - - - - - - - - - 1 2 3 4 5
`I_11` : - - - - - - - - - - 1 2 3 4 5
`I_12` : - - - - - - - - - - - 1 2 3 4 5
So number of clocks required to complete the program is = 15 clocks and time taken is = 15
×11 ns=165 ns.
Answer: (A) and (D)
`not` `exists` x (`forall` y(`alpha`) `and` `forall` z(`beta`))
`equiv` `forall` x [`forall` y (`alpha`) `rightarrow` `exists` z(`not` `beta` )]option "c" [`because` `not` (p `and` q) `equiv` p `Rightarrow` `not` q]
`equiv` `forall` x [`forall` z(`beta`)`rightarrow` `exists` y (`not` `alpha`)]option "B" [`because` p `Rightarrow` q `equiv` `not` q `Rightarrow` `not` p]