0% found this document useful (0 votes)
20 views7 pages

CS 2017 - Set 1-Watermark - pdf-42

The document is the homepage for www.gradeup.co, which provides general aptitude and computer science practice questions and tests. It includes sample questions on topics like data structures, algorithms, logic, and math. The questions have multiple choice answers to help users prepare for exams.

Uploaded by

Bruce Wayne
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)
20 views7 pages

CS 2017 - Set 1-Watermark - pdf-42

The document is the homepage for www.gradeup.co, which provides general aptitude and computer science practice questions and tests. It includes sample questions on topics like data structures, algorithms, logic, and math. The questions have multiple choice answers to help users prepare for exams.

Uploaded by

Bruce Wayne
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/ 7

www.gradeup.

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?

Assume for all inputs (a, b, c, d) the respective


complements a,b ,c , d  are also available. The

above logic is implemented 2-input NOR gates only.


A. P,Q B. P,Q,T The minimum number of gates required is _____.
C. R,S,T D. Q,R,S A. 0 B. 1
7. “The hold of the nationalist imagination on our C. 2 D. 3
colonial past is such that anything inadequately or 3. The statement (¬p) (¬q) is logically equivalent to
improperly nationalist is just not history” which of the statements below?
Which of the following statements best reflects the I. p ⇒ q II. q ⇒ p
author’s opinion? III. (¬q) ∨ p IV. (¬q) ∨ q
A. Nationalists are highly imaginative. A. I only B. I and IV only
B. History is viewed through the filter of nationalism. C. II only D. II and III only
C. Our colonial past never happened. 4. Consider the following table:
D. Nationalism has to be both adequately and
properly imagined.

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 ba  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  ab
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 pq
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 WX
A. B.
II. y  xR  x, y   Y V Y V
III. y  xR  x, y   Y Z Y Z
IV. x  yR  x, y   V W V W
A. IV only B. I and IV only VX WX
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 YX YX
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
*

(0,128,256,128,0,128,256,128,1,129,257,129,1,12 of the following statements is true:


9,257,129) is repeated 10 times. The number of A. f if computable if and only if Lf is recursive.
conflict misses experienced by the cache is B. f is computable if and only Lf recursively
__________. enumerable.
A. 43 B. 56 C. If f is computable then Lf is recursive, but not
C. 63 D. 76 conversely.
D. If f is computable then Lf is recursively
41. Let u and v be two vectors in whose Euclidean norms
enumerable, but not conversely.
satisfy What is the value of such that bisects the
45. Consider the expression
angle between u and v?
 a  1    b  c  / 3  d . Let X be the minimum
*
A. 2 B. ½
C. 1 D. -1/2 number of registers required by an optimal code
42. Consider the following grammar: generation (without any register spill) algorithm for
stmt → if exp r then else exp r ;stmt 0 a load/store architecture in which (i) only loads and
exp r → termrelop term term store instructions can have memory operands and
(ii) arithmetic instructions can have only register or
term → id | number
immediate operands. The value of X is _____.
if → a | b | c A. 0 B. 1
number → [0…9] C. 2 D. 3
where relop is a relational operate (e.g <, >,….) --- 46. Let G = (V, E) be any connected undirected edge-
O refers to the empty statement, and if, then, else weighted graph. The weights of the edges in E are
are terminals. positive and distinct. Consider the following
Consider a program P following the above grammar statements:
containing ten if terminals. The number of control (I) Minimum spanning tree of G is always unique.
flows paths in P is _____. For example the program (II) Shortest path between any two vertices of G is
if e1 then e2 else e3 always unique.
Which of the above statements is/are necessarily
has 2 controls flow paths e1 → e2 and e1 → e3
true?
A. 128 B. 512 A. (I) only B. (II) only
C. 1024 D. 2048 C. Both (I) and (II) D. Neither (I) nor (II)
43. In a database system, unique time stamps are 47. A multithreaded program P executes with x number
assigned to each transaction using Lamport’s logical of threads and uses y number of locks for ensuring
clock. Let TS(T1) and TS(T2) be the timestamps of mutual exclusion while operating on shared memory
transactions T1 and T2 respectively. Besides, T1 holds locations. All locks in the program are non-re-
a lock on the resource R, and T2 has requested a entrant, i.e., if a thread holds a lock l, then it cannot
conflicting lock on the same resource R. The re-acquire lock l without releasing it. If a thread is
following algorithm is used to prevent deadlocks in unable to acquire a lock, it blocks until the lock
the database system assuming that a killed becomes available. The minimum value of x and the
transaction is restarted with the same timestamp. minimum value of y together for which execution of
if TS(T2) < TS(T1) then P can result in a deadlock are:
A. x = 1, y = 2 B. x = 2, y = 1
T1 is killed
C. x = 2, y = 2 D. x = 1, y = 1
else T2 waits. 48. The values of parameters for the Stop-and – Wait
Assume any transactions that is not killed terminates ARQ protocol are as given below:
eventually. Which of the following is TRUE about the Bit rate of the transmission channel = 1 Mbps
database system that uses the above algorithm to Propagation delay from sender to receiver = 0.75 ms
prevent deadlocks? Time to process a frame = 0.25 ms
A. The database system is both deadlock-free and Number of bytes in the information frame = 1980
starvation- free. Number of bytes in the acknowledge frame = 20
B. The database system is deadlock-free, but not Number of overhead bytes in the information frame
starvation-free. = 20
C. The database system is starvation-free but not Assume that there are no transmission errors. Then
deadlock-free. the transmission efficiency (expressed in
percentage) of the Stop-and – Wait ARQ protocol for
D. The database system is neither deadlock-free nor
the above parameters is _____.
starvation-free.
A. 75.33 B. 89.33
C. 92.33 D. 99.33

6|Page
www.gradeup.co

49. A computer network uses polynomials over GF(2) for


error checking with 8 bits as information bits and The following query is made on the database.
uses x3 + x + 1 as the generator polynomial to T 1   Course Name  Student Name ' SA '  CR  
generate the check bits. In this network, the
message 01011011 is transmitted as T 2  CR  T 1
A. 01011011010 B. 01011011011 The number of rows in T2 is _____.
C. 01011011101 D. 01011011100 A. 2 B. 3
50. Let p, q, and r be propositions and the expression C. 4 D. 5
(p → q) → r be a contradiction. Then, the expression 54. Let A be real valued square symmetric matrix of rank
(r → p) → q is n n
A. a tautology
B. a contradiction
2 with
 A
i 1 j 1
2
ij  50. Consider the following

C. always TRUE when p is FALSE


statements.
D. always TRUE when q is TRUE
(I) One eigen value must be in [-5, 5]
51. A cache memory unit with capacity of N words and
(II) The eigen value with the largest magnitude must
block size of B words is to be designed. If it is
be strictly greater than 5.
designed as a direct mapped cache, the length of the
Which of the above statements about eigen values
TAG field is 10 bits. If the cache unit is now designed
of A is/are necessarily CORRECT?
as a 16-way set-associative cache, the length of the
A. Both (I) and (II) B. (I) only
TAG field is ______ bits.
C. (II) only D. Neither (I) nor (II)
A. 12 B. 14
55. Consider the context-free grammars over the
C. 16 D. 18
alphabet {a,b,c} given below. S and T are non-
52. Consider the following two functions.
terminals
void fun1 (int n) {
if (n == 0 ) return; G1 : S  aSb T , T  cT 
printf (“%d” , n);
G2 : S  bSa T , T  cT 
fun2 (n - 2);
printf (“%d” , n); The language L  G1   L  G2  is
}
A. Finite
void fun2 (int n) {
B. Not finite but regular
if (n = = 0) return ;
C. Context-free but not regular
printf (“%d” , n);
D. Recursive but not context-free
fun1(++n) ;
printf (“%d” , n);
}
The output printed when fun1(5) is called is
A. 53423122233445 B. 53423120112233
C. 53423122132435 D. 53423120213243
53. Consider a database that has the relation schema CR
(StudentName, CourseName). An instance of the
schema CR is as given below.

***

7|Page

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy