CS 2017 - Set 1-Watermark - pdf-42
CS 2017 - Set 1-Watermark - pdf-42
co
General Aptitude 9. Six people are seated around a circular table. There
are at least two men and two women. There are at
1. Research in the workplace reveals that people work least three right-handed persons. Every woman has
for many reason _____. a left-handed person to her immediate right. None
A. money beside B. beside money of the women are right-handed. The number of
C. money besides D. besides money women at the table is
A. 2 B. 3
2. After Rajendra chola returned from his voyage to
C. 4 D. Cannot be determined
Indonesia, he ____ to visit the temple in Thanjavur.
10. Arun, Gulab, Neel and Shweta must choose one shirt
A. was wishing B. is wishing each from a pile of four shirts coloured red, pink,
C. wished D. had wished blue and white respectively. Arun dislikes the colour
3. Rahul Murali, Srinivas and Arul are seated around a red and Shweta dislikes the colour white. Gulab and
square table. Rahul is sitting to the left of Murali. Neel like all the colours. In how many different ways
Srinivas is sitting to the right of Arul. Which of the can they choose the shirts so that no one has a shirt
following pairs are seated opposite each other? with a colour he or she dislikes?
A. Rahul and Murali B. Srinivas and Arul A. 21 B. 18
C. Srinivas and Murali D. Srinivas and Rahul C. 16 D. 14
4. Find the smallest number y such that is a perfect
cube. Computer Science
A. 24 B. 27
1. Let X be a Gaussian random variable mean 0 and
C. 32 D. 36
variance σ2. Let Y = max(X, 0) where max (a, b) is
5. The probability that a k-digit number does NOT the maximum of a and b. The median of Y is _____.
contain the digits 0,5,or 9 is
A. 0 B. 1
A. 0.3* B. 0.6*
C. 2 D. 3
C. 0.7* D. 0.9*
2. Consider the Karnaugh map given below, where x
6. A contour line joins locations having the same height represents “don’t care” and blank represents 0.
above the mean sea level. The following is a contour
plot of a geographical region. Contour lines are
shown at 25m intervals in this plot. If in a flood, the
water level rises to 525m, which of villages P, Q, R,
S, T get submerged?
8. The expression
x y x y is equal to
2
A. the maximum of x and y Match the algorithms to the design paradigms they
B. the minimum of x and y are based on.
C. 1 A. P-(ii), Q-(iii), R-(i) B. P-(iii), Q-(i), R-(ii)
D. None of the above C. P-(ii), Q-(i), R-(iii) D. P-(i), Q-(ii), R-(iii)
1|Page
www.gradeup.co
5. A sender S sends a message m to receiver R, which 11. Let C1 …… Cn be scalars, not all zero, such that
is digitally signed by S with its private key. In this n
scenario, one or more of the following security
violations can take place.
c a
i 1
i i 0 where are column vectors in Rn.
I. S can launch a birthday attack to replace m with a Consider the set of linear equations Ax = b
fraudulent message. n
II. A third party attacker can launch a birthday where A = [a1….an] and b ai . The set of
attack to replace m with a fraudulent message. i 1
III. R can launch a birthday attack to replace m with
equations has
a fraudulent message.
A. a unique solution at x = jn where jn denotes a n-
Which of the following are possible security dimensional vector of all 1
violations? B. no solution
A. I and II only B. I only C. infinitely many solutions
C. II only D. II and III only D. finitely many solutions
6. Consider the following grammar. 12. Consider the C code fragment given below.
typedef struct node {
int data;
node* next ;
} node;
void join (node* m, node* n) {
node* p=n ;
while (p->next ! =NULL){
What is FOLLOW (Q)? p = p –> next ;
A. {R} B. {w} }
C. {w, y} D. {w, $} p–> next = m;
}
7. Consider the language L given by the regular
Assuming that m and n point to valid NULL-
a b ba b
*
expression over the alphabet terminated linked lists, invocation of join will
{a, b}. The smallest number of states needed in a A. append list m to the end of list n for all inputs
deterministic finite-state automation (DFA) B. either cause a null pointer dereference or append
list m to the end of list n
accepting L is ______.
C. cause a null pointer dereference for all inputs
A. 2 B. 3
D. append list n to the end of list m for all inputs
C. 4 D. 5 13. The n-bit fixed-point representation of an unsigned
8. Consider a two-level cache hierarchy with L1 and L2 real number real X uses f bits for the fraction part.
caches. An application incurs 1.4 memory accesses Let The range of decimal values for X in this
per instruction on average. For this application, the representation is
miss rate of L1 cache 0.1, the L2 cache experiences, A. 2-f to 2i B. 2-f to (2i – 2-f)
on average, 7 misses per 1000 instructions. The C. 0 to 2 i D. 0 to (2i – 2-f)
miss rate of L2 expressed correct to two decimal 14. Consider the following intermediate program in three
places is _____. address code
A. 0.05 B. 0.07
p ab
C. 0.03 D. 0.01
9. Consider the following CPU processes with arrival q q *c
times (in milliseconds) and length of CPU burst (in
milliseconds) as given below: p u *v
q pq
Which one of the following corresponds to a static
single assignment form of the above code?
p1 a b p3 a b
If the pre-emptive shortest remaining time first
A.
q1 p1 * c B.
q4 p3 * c
scheduling algorithm is used to schedule the
processes., then the average waiting time across all p1 u * v p4 u * v
processes is ____ milliseconds.
A. 0 B. 1 q1 p1 q1 q5 p4 q4
C. 2 D. 3 p1 a b p1 a b
10. Threads of a process share
A. global variable but not heap C.
q1 p2 * c D.
q1 p2 * c
B. heap but not global variables p3 u * v p2 u * v
C. neither global variables nor heap
D. Both heap and global variables q2 p4 q3 q2 p q
2|Page
www.gradeup.co
15. Consider the C struct defined below: carry bits are C7…..C0. An overflow is said to have
struct data { occurred if
int marks [100]; A. the carry bit C7 is 1
char grade; B. all the carry bits C7…..C0 are 1
int cnumber;
};
C. A B .S A .B .S is 1
7 7 7 7 7 7
D. A .B .S A .B .S is 1
struct data student;
The base address of student is available in register 0 0 0 0 0 0
R1. The field student.grade can be accessed
20. Consider a database that has the relation schema
efficiently using
EMP (EmpId, EmpName, and DeptName).
A. Post-increment addressing mode. (R1)+
An instance of the schema EMP and a SQL query on
B. Pre-decrement addressing mode, -(R1)
it are given below.
C. Register direct addressing mode, R1
D. Index addressing mode, X(R1), where X is an
offset represented in 2’s complement 16- bit
representation.
16. Consider a TCP client and a TCP server running on
two different machines. After completing data
transfer, the TCP client calls close to terminate the
connectional and a FIN segment is sent to the TCP
server. Server-side TCP responds by sending an ACK
which is received by the client-side TCP. As per the
TCP connections state diagram (RFC 793), in which
state does the client-side TCP connection wait for the
FIN from the sever-side TCP?
A. LAST-ACK B. TIME-WAIT
C. FIN-WAIT-1 D. FIN-WAIT-2
17. Consider the following context-free grammar over
the alphabet ∑ = {a,b,c} = {a,b,c} with S as the
start symbol.
S abScT | abcT
T bT | b
Which one of the following represents the language
generated by the above grammar?
A. ab cb | n 1
n n
The output of executing the SQL query is _____.
A. 0.3 B. 1.4
B. ab cb cb ...cb
n m1 m1 mn
| n, m1 , m2 ,...mn 1
21.
C. 2.6 D. 3.1
The following functional dependencies hold true for
C.
ab cb | m, n 1
n m n
the relational schema R{V, W, X, Y, Z}:
V W
D.
ab cb | m, n 1
n n m VW X
Y VX
18. Consider the first-order logic sentence
f : z yR x, y . Assuming non-empty logical Y Z
Which of the following is irreducible equivalent for
domains, which of the sentences below are implied this set of functional dependencies?
by F? V W V W
I. y xR x, y V W WX
A. B.
II. y xR x, y Y V Y V
III. y xR x, y Y Z Y Z
IV. x yR x, y V W V W
A. IV only B. I and IV only VX WX
C. II only D. II and III only C. D. Y V
19. When two 8-bit numbers A7…A0 and B7…B0 in 2’s
Y V
complement representation (with A0 and B0 as the YX YX
least significant bits) are added using a ripple-carry
adder, the sum bits obtained are S7….S0 and the Y Z Y Z
3|Page
www.gradeup.co
22. Consider the following functions from positive 26. Consider a combination of T and D flip flip-flop is
integers to real numbers: connected to the input of the connected to the input
of the D flip-flop is connected to the input of the T
100
10, n , n,log 2 n, flip-flop and the output of the T Flip-flop is connected
n to the input of the D Flip-flop,
The CORRECT arrangement of the above functions in
increasing order of asymptotic complexity is:
100
A. log 2 n, ,10, n , n
n
100 Initially, both Q0 and Q1 are set to 1 (before the 1
B. ,10,log 2 n, n , n
n clock cycle). The outputs
A. Q1Q0 after the 3rd cycle are 11 and after the 4
100 B. Q1Q0 after the 3rd cycle are 11 and after the 4
C. 10, n ,log 2 n, n
n C. Q1Q0 after the 3rd cycle are 00 and after the 4
D. Q1Q0 after the 3rd cycle are 01 and after the 4
100
D. ,log 2 n,10, n , n 27. The number of integers between 1 and 500 (both
n inclusive) that are divisible by 3 or 5 or 7 is ______.
23. Let T be a tree with 10 vertices. The sum of the A. 212 B. 271
degrees of all the vertices in T is _____. C. 311 D. 354
A. 0 B. 10 28. Consider a RISC machine where each instruction is
C. 18 D. 20 exactly 4 bytes long. Conditional and unconditional
24. Let T be a binary search tree with 15 nodes. The branch instructions use PC- relative addressing
minimum and maximum possible heights of T are: mode with Offset specified in bytes to the target
location of the branch instruction. Further the Offset
Note: The height of a tree with a single node is 0.
is always with respect to the address of the next
A. 4 and 15 respectively instruction in the program sequence. Consider the
B. 3 and 14 respectively following instruction sequence.
C. 4 and 14 respectively
D. 3 and 15 respectively
25. Consider the following C code:
# include <stdio.h>
int * assignval (int *x, int val) {
*x = val;
If the target of the branch instruction is i, then the
return x; decimal value of the Offset is _____.
} A. -10 B. -16
void main ( ) { C. -22 D. -25
int * x= malloc (sizeof (int)); 29. Consider the C functions foo and bar given below:
if (NULL = = x) return; int foo (int val ) {
x = assignval (x,0); int x = 0;
if(x) { while (val > 0) {
x=(int *) malloc (sizeof (int)); x = x + foo ( val --);
if (NULL = = x) return; }
x = assignval (x, 10); return val ;
} }
printf(“%d\n”, *x); int bar (int val ) {
free (x); int x = 0;
} while (val > 0) {
The code suffers from which one of the following x = x + bar (val – 1) ;
problems: }
A. compiler error as the return of malloc is not return val ;
typecast appropriately. }
B. compiler error because the comparison should be Invocations of foo (3) and bar (3) will result in:
made as x==NULL and not as shown. A. Return of 6 and 6 respectively.
C. compiles successfully but execution may result in B. Infinite loop and abnormal termination
dangling pointer. respectively.
D. compiles successfully but execution may result in C. Abnormal termination and infinite loop
memory leak. respectively.
D. Both terminating abnormally
4|Page
www.gradeup.co
30. In a RSA cryptosystem a participant A uses two 36. Recall that Belady’s anomaly is that the pages-fault
prime numbers p = 13 and q = 17 to generate her rate may increase as the number of allocated frames
public and private keys. If the public key of A is 35. increases. Now consider the following statements:
Then the private key of A is ______. S1: Random page replacement algorithm (where a
A. 09 B. 11 page chosen at random is replaced) suffers from
C. 21 D. 31 Belady’s anomaly
31. Let A be an array of 31 numbers consisting of S2: LRU page replacement algorithm suffers from
sequence of 0’s followed by a sequence of 1’s. The Belady’s anomaly
problem is to find the smallest index i that A[i] is 1 Which of the following is CORRECT?
by probing the minimum numbers of locations in A. A. S1 is true, S2 is true B. S1 is true, S2 is false
The worst case number of probes performed by an
C. S1 is false, S2 is true D. S1 is false, S2 is false
optimal algorithm is _____.
37. The output of executing the following C program is
A. 2 B. 3
____.
C. 4 D. 5
32. If G is grammar with productions # include <stdio.h>
int total (int v) {
S SaS | aSb | bSa | SS |
while (v) {
where S is the start variable,
count + = v & 1;
then which one of the following is not generated by
G? v>> = 1;
A. abab B. aaab }
C. abbaa D. babba return count;
}
x 7 2 x5 1
33. The value of lim void main ( ) {
x 1 x3 3x 2 2 static int x = 0;
A. is 0 B. is -1 int i = 5;
C. is 1 D. does not exist for (; i> 0; i--) {
34. Instructions execution in a processor is divided into x=x + total (i) ;
5 stages. Instruction Fetch (IF), Instruction Decode }
(ID), Operand Fetch (OF), Execute (EX), and Write printf (“%d\n”, x) ;
Back (WB), These stages take 5,4,20, 10 and 3
}
nanoseconds (ns) respectively. A pipelined
A. 12 B. 23
implementation of the processor requires buffering
between each pair of consecutive stages with a delay C. 31 D. 44
of 2ns. Two pipelined implementations of the 38. Consider the following C program.
processor are contemplated. #include <stdio.h>
(i) a naïve pipeline implementation (NP) with 5 #include<string.h>
stages and void printlength (char *s, char *t) {
(ii) an efficient pipeline (EP) where the OF stage id unsigned int c = 0;
divided into stages OF1 and OF2 with execution int len = ((strlen(s) – strlen (t)) > c) ? strlen(s):
times of 12 ns and 8 ns respectively. strlen(t);
The speedup (correct to two decimals places) printf (“%d\n”, len);
achieved by EP over NP in executing 20 independent }
instructions with no hazards is _____.
void main ( ) {
A. 0.43 B. 1.50
char *x = “abc”;
C. 2.31 D. 3.23
35. Consider a database that has the relation schemas char *y =”defgh”;
EMP(EmpId, EmpName, DepId). And printlength (x,y);
DEPT(DeptName, DeptId). Note that the DeptId can Recall that strlen is defined in string.h as returning a
be permitted to be NULL in the relation EMP. value of type size_t, which is an unsigned int. The
Consider the following queries on the database output of the program is _____.
expressed in tuple relational calculus. A. 1 B. 2
{t | u EMP(t[ Emp Name] u[ Emp Name] C. 3 D. 4
I. 39. Consider the following languages over the alphabet
v DEPT t DeptId v[ DeptId ])) }
{t | u EMP(t[ Emp Name] u[ Emp Name] a, b, c
II.
v DEPT t DeptId v[ DeptId ])) } Let L1 a n bn c m | m, n 0 and
III.
{t | u EMP(t[ Emp Name] u[ Emp Name] L2 a m bn c n | m, n 0
v DEPT t DeptId v[ DeptId ])) } Which of the following are context-free languages?
Which of the above queries are safe? I. L1 L 2 II. L1 L 2
A. (I) and (II) only B. (I) and (III) only
A. I only B. II only
C. (II) and (III) only D. (I), (II) and (III)
C. I and II D. Neither I nor II
5|Page
www.gradeup.co
40. Consider a 2-way set associative cache with 256 44. Let A and B be infinite alphabets and let # be a
blocks and uses LRU replacement, Initially the cache symbol outside both A and B. Let f be a total
is empty. Conflict misses are those misses which functional from A* to B*. We say f is computable if
occur due the contention of multiple blocks for the there exists a Turning machine M which given an
same cache set. Compulsory misses occur due to input x in A*, always halts with f(x) on its tape. Let
first time access to the block. The following sequence
of accesses to memory blocks.
Lf denote the language x # f x | x A . Which
*
6|Page
www.gradeup.co
***
7|Page