Computer Science And IT (CS/IT) Mock Test For Gate

65 Questions MCQ Test GATE Computer Science Engineering(CSE) 2023 Mock Test Series | Computer Science And IT (CS/IT) Mock Test For Gate

Attempt Computer Science And IT (CS/IT) Mock Test For Gate | 65 questions in 180 minutes | Mock test for GATE preparation | Free important questions MCQ to study GATE Computer Science Engineering(CSE) 2023 Mock Test Series for GATE Exam | Download free PDF with solutions

In the following question, some part of the sentence may have errors. Find out which part of the sentence has an error and select the appropriate option. If the sentence is free from error, select 'No error'.The fox thought to him

The fox thought to him (A)/ that he should wait for the (B)/ lady to leave the place.(C)/ No error


The error lies in part (A) of the sentence as the pronoun ‘him’ is incorrect and must be replaced with a reflexive pronoun ‘himself’ which is used as the object of a verb or preposition to refer to a male person or animal previously mentioned as the subject of the clause.


A book shelf has 27 books – 9 books each written by 3 eminent authors. If Raj selects any 2 books without booking at their author’s name, what is the probability that he picks up books written by the different authors.


Total possible outcomes  = 27C2

Favourable outcomes = Selecting any two authors × selecting one book for each author=


The ratio material cost and labor cost in a small construction project is 3:1. If the labor cost went up by 20% and material cost witnessed an avenge increase of 15%, what will be the new ratio of labor cost and material cost?


Let us take material cost and labor cost as Rs 300 and Rs 100 respectively. Since labor cost went up by 20%, the revised labor cost is Rs 120. The revised material cost due to 15% increase is Rs (300+15% of 300) = 345. The ratio of labor cost and material cost is 120: 345 or 8: 23 i.e. (b)


A monkey is trying to reach the top of a tree. He climbs 3 feet in a minute but slides down by 1.5 feet after each climb. If he reaches the top of the tree in 58 minutes, then the maximum possible height of the tree is ____ feets.


You have to carefully observe the point that in the last minute, we DO NOT have to consider the sliding down of the monkey since the question states that the monkey reaches the top of the tree.Out of 58 minutes, the climb by monkey in 58th minute is 3 feet whereas for each of his earlier climbs, the monkey covers a net distance of 3-1.5=1.5  feet.We can work out the maximum possible height of the tree as 1.5×57+3=85.5+3=88.5 feet


Direction: Read the sentence to find out whether there is any error in it. The error, if any, will be in one part of the sentence. If the given sentence is correct as it is, mark E i.e. No error as the answer. Ignore the errors of punctuation, if any.The misuse of drugs and alcohol were seen as very damaging/ to the society, chiefly because it often promoted/ violent crimes and anti-social behavior; while also/ causing ill-health, poverty and family breakdown.


The error lies in the first part of the sentence where the verb ‘were’ is incorrect and needs to be replaced with ‘was’ as the subject "misuse" is singular. To make the subject and the verb agree it should read as:’The misuse of drugs and alcohol was seen as..’


An event A is considered to be rolling a fair dice .If 10 dice are rolled each of which are independent, find the probability that the sum obtained on the faces is between 30 and 40 both inclusive.

Given: N(1.0184) = 0.84 , which is value of normal distribution for X = 1.018


Let Xi denote the ith dice.

Since events are independent,

E(xi) = 7/2

V(xi) = 350/12

According to Central Limit Theorem,

P(30≤ X ≤40) = P(30 – 35 ≤ X – 35 ≤ 40-35)

Its converting to standard form, X – E[X] / std, where std is standard deviation.


P = 2N(1.0184) – 1

= 0.69


Which of the given option is most appropriate in the context of the word in bold letters in the given sentence.The reason there is no exodus towards banks in general for new project funding is their relatively less experience in project appraisal.


Migration is the only word which comes to the meaning of the word ‘exodus.’


Improve the bracketed part of the sentence. My car (broke off) on my way to the office.


Let's understand the meanings of each phrasal verb given in the options:

Broke off = became separated/detached

Broke out = started/began suddenly

Broke in = force entry to a building

Broke down = suddenly ceased or stopped to function (of a machine or motor vehicle)

As per the context of the sentence, the correct phrasal verb is "broke down".


Chinnaswamy is driving to pick up his son from school on a Saturday which is a half day. On his way to school, he crossed a church which is 1/5th of the way to school at 9:50 hours and exactly 10 minutes later, he went past a temple which is 1/3rd of the way to school. The time after 10:00 hours at which he reaches his son’s school is ____ minutes.


Since we are given time to cross a point which is 1/5th of the way and 1/3rd of the way, we can rewrite them as 3/15th and 5/15th of the way which implies that 2/15th of the way was covered in 10 minutes.
This means that the entire route was covered in 10 × 15/2 = 75 minutes (each 1/15th part is covered in 75/15 = 5 minutes) leading to time of arrival at school as 9:50 – 15 + 75 = 10:50 hours.


In the following question, out of the four alternatives, select the word similar in meaning to the given word.Literal


Literal = line for line, letter to letter
Verbatim = in exactly the same words; word for word
Formal = conventional, traditional
Idealistic = visionary, dreamy, unrealistic
Outdated = out of date, obsolete
Hence, "Verbatim" best expresses the meaning of the word "Literal".


In control flow analysis, control flow graph contain basis blocks for the code.

A basic block is a segment of the code that a program must enter at the beginning and it can exit only at the end. A basic block ends in which of the following ways?


A basic block can end in any of the following:Jump statementConditional/ unconditional branchReturn statement


Which of the following operators is used to search a specified pattern in a column?


The like operator is used in the string to search for characters. Eg: All names starting with ‘A’ (select name from ABC were name like ‘A%’;) while where is used to check for the condition.


Draw the process state transition diagram of an OS in which (i) each process is in one of the five states: created, ready, running, blocked (i.e. sleep or wait), or terminated, and (ii) only non-preemptive scheduling is used by the OS. Label the transitions appropriately.


The following typical process states are possible on computer systems of all kinds. In most of these states, processes are "stored" on main memory.
Created: When a process is first created, it occupies the "created" or "new" state. Ready and waiting: A "ready" or "waiting" process has been loaded into main memory and is awaiting execution on a CPU. There may be many "ready" processes at any one point of the system's execution.
Running: A process moves into the running state when it is chosen for execution. The process's instructions are executed by one of the CPUs (or cores) of the system. There is at most one running process per CPU or core. A process can run in either of the two modes, namely kernel mode or user mode.
Kernel mode : Processes in kernel mode can access both: kernel and user addresses.Kernel mode allows unrestricted access to hardware including execution of privileged instructions.
User mode : Processes in user mode can access their own instructions and data but not kernel instructions and data .access to any hardware device is allowed.
Blocked : A process that is blocked on some event (such as I/O operation completion or a signal), may be blocked due to various reasons, such as exhausting its CPU time allocation or waiting for an event to occur.
Terminated : A process may be terminated, either from the "running" state by completing its execution or by explicitly being killed


An instruction is stored at location 300 with its address field at location 301. The address field has the value 400. A processor register R1 contains the number 200. What will be the addressing mode of the effective address of the instruction is 702?


Relative: 302 + 400 = 702


A file system is said to exhibit data dependence because;


A file system is said to exhibit data dependence because a change in any file’s structure, such as addition or deletion of a field, requires modifications of all programs using that file. That means, access to a file is dependent on its structure.
A file system is said to exhibit data dependence because a change in any file’s data characteristics, such as changing the filed from integer to decimal, requires change in all data access programs. That means, access to a file data is dependent on its data characteristics.


Choose the correct option to fill the empty blanks in below statement :If variables are declared previously, then __________ is responsible for generation of symbol table but if variables are not declared then symbol table will be generated by __________.


If variables are declared previously, then semantic analyzer is responsible for generation of symbol table.

If variables are not declared, then lexical analyzer will generate the symbol table.

Hence option b is correct.


Above process arrive in the order P1, P2, P3 and are served in FCFS order. Then average waiting time is:


Gantt chart for the given situation is:

Now, the waiting time is 0 milliseconds for process P1, 22 unit for process P2 and 27 unit for process P3

Thus, the average waiting time = (0 + 27 + 22)/ 3 = 49/3 = 16.33 = 16 units.


Initially a priority queue had 5 elements and it is being implemented as Max-Heap. Let’s say the level order traversal of the heap is: 30, 18, 17, 12, 11. Now two more elements are inserted into the heap i.e. 10 and 19 in the same order. The level order traversal of the heap after the insertion is:


So, the insertion is followed in the same order, hence, we will insert 10 first which doesn’t effect the tree. Now, we insert 19. After insertion of 19 max_heapify founds an error in the node 17 → 11, 17 → 19. So, 19 is send up and 17 is brought down. After that the level order traversal changes to 30, 18, 19, 12, 11, 10, 17


Create a view which gives students number and name for those who enrolled in class ”Database Design” and whose age is under 25.


Following is the syntax for creating views.


SELECT column_name(s)

FROM table_name

WHERE condition


Consider the following C program:

int main(){

printf("what %%");

return 0;

What does the code print?


Backslash actually acts an escape character and helps to print double quotes, where % can be printed only with double % i.e. %%


Consider a program which stores the frequency of marks of student in a particular subject say Mathematics. The marks is in the range [0...100] and there are around 500 students. But there is one condition we only want to record frequency if the student has passed in the exam, the passing marks being 40. What is the best way to store the frequency of marks above 40?


For this purpose, we can ignore the below forty numbers and have an array of 60 index to store the individual frequencies from 40 to 100.

*Answer can only contain numeric values

A fair die with faces {1, 2, 3, 4, 5, 6} is thrown repeatedly till ‘3’ is observed for the first time. Let X denote the number of times the die is thrown. The expected value of X is _____.



now, the random variable X does represent number of throws required for getting 3. So,


The alternate way of writing the instruction, SUB #7,R1 is______. The above addressing mode is Immediate addressing mode


The SUBI instruction, means the subtraction is in immediate addressing mode.


Which one of the following is a closed form expression for the generating function for the sequence {Sn}, where Sn = an, for all n = 0, 1, 2, …… and ‘a’ is a constant?


The given sequence is <1, a1, a2, a3, a4, ………..>.

The generating function for this sequence will be;

The only generating sequence that matching the above sequence is of option D


Given two complex numbers,  the argument of z1/z2 in degrees is


since , we know that 

Since we know that


An athlete can play on several teams and each team needs atleast one player. 

Based on the description above, what is the maximum cardnality between each instance of “Athelete” and “team”?


As it is clearly mentioned that each team at least require one player so one team can acquire n number of athletes where n>=1. And also one athlete can play for more than one team i.e for m teams. So maximum cardinality is m:n


Find the type of given grammar:

S -> #S | @ A#

A -> @ A @ | #B!A

B -> &B% | ! | e

Non Terminal (V) = { S , A , B }

Terminal (T) = { # , ! , @ , % , & }

Here e is epsilon or null symbol.


To check LL(1) we have to use some rules :
i. First(A1) ∩ First(A2) ∩ ...... ∩ First(An) = Ø
Where , A -> A1 | A2 | A3 ...... | An
ii. If any production contains null then do as follow
First(Ai) ∩ Follow(Ai) = Ø
If the above two rules satisfy then given grammar is LL(1) , but as per grammar given in question it is not satisfying above rule in production of B [ First(B) ∩ Follow(B) != Ø ].
To check LR(0) when we draw DFA for each item in Goto and Clousre , there is shift and reduce conflict.
Same case is with SLR(1) , in production B , there is shift reduce conflict.


What is the unit digit of number obtained from: 111283+171293 - 71283


We don’t need to calculate the final result, just calculate the unit digit raised to the power of unit digit of power of each term and add it. So,  1+7-3=5


Consider the following system of equations.

x+y = 2

x+py = 2

where p is constant. Find the value of ‘p’ such that the system has more than two solutions.



When number of entities are bought together into one entity based on their similar characteristics, what is this process called;


In the above example food items are generalized on the basis that they all belong to fast food.



Let S be the reference string and X, Y be the no. Of page fault occur using the optimal and LRU page replacement policies respectively. Let SR be the reverse of S, and X' and Y' be the no. Of page fault occur using the optimal and LRU page replacement policies respectively. Which of the following is true?


It is the property of Optimal and LRU page replacement that S and SR will have same number of page fault.

Also, FIFO suffer from Belady’s anomaly but LRU and Optimal do not suffer from belady’s anomaly.


Consider 4-block cache (initially empty) with the following main memory block references.
4, 5, 7, 12, 4, 5, 13, 4, 5, 7
Identify the hit ratio for Direct mapped cache?


{K MOD N = i}

4-M: 4 MOD 4 = 0

5-M: 5 MOD 4 = 1

7-M: 7 MOD 4 = 3

12-M: 12 MOD 4 = 0

4-M; 4 MOD 4 = 0


13-M; 13 MOD 4 = 1


5-M; 5 MOD 4 = 1


H = 3/10 = 0.3


Find the output

#include <iostream>

#define cnct(x,y) x##y

using namespace std;

class {


int p,q,pq;

int f1()



return (p+++q);



int main(){



return 0;



41, 11

Class without name is allowed. In this case object of class is created along with definition.

cnct(x,y) x##y ,## is a preprocessor macro used for concatenation.

x##y= xy

Call this creates a single terms named xy,here in main pq; cnct(p,q) places value of pq in its position that is 15.



P+++q is interpreted here as p++ + q(1st two for post increment operator,3rd one operator for adding )

Plus operator(+) has higher precedence than post increment operator. So, Value of p & q (5 & 6) get added before p increments. So, p+++q->11


The height of a tree is the length of the longest root to leaf path in it. The maximum and minimum number of nodes in a binary tree of height 4 is.


Height is defined as path length i.e (height+1) will give number of levels. In a binary tree of height h = 4;

Maximum number of nodes = 2^(h+1)-1

= 31

Minimum number of nodes = 5

Therefore (d) is correct answer.


The five aggregations operators in SQL are;


SQL uses the five aggregations operators SUM, AVG, MIN, MAX and COUNT. These operators are used by applying them to a scalar-valued expressions, typically a column name, in a SELECT clause.


Dijkstra’s single source shortest path algorithm when run from vertex a in the above graph, computes the correct shortest path distance to;


Dijkstra's single source shortest path is not guaranteed to work for graphs with negative weight edges, but it works for the given graph.

Let us see...

Let us run the 1st pass b 1 b is minimum, so shortest distance to b is 1

After 1st pass, distances are c 3. e -2. e is minimum, so shortest distance toe is -2 After 2nd pass, distances are c 3, f 0. f is minimum, so shortest distance t of is 0 After 3rd pass, distances are c 3, g 3. Both are same, let us take g. so shortest distance to g is 3. After 4th pass, distances are c 3, h 5 c is minimum, so shortest distance to c is 3 After 5th pass, distances are h -2 h is minimum, so shortest distance to h is -2.

*Answer can only contain numeric values

Consider a company, where a team is having seven different tasks. We have to complete these tasks with only four employees. Among these task, one task is tougher than other tasks. Similarly, we have one employee that is better than among other employees. In how many ways we can seven different tasks be assigned to four different employees so that each employee is assigned at least one task and the most difficult task is assigned to the best employee is _____________?


As seen in the above image, best job is already assign to the best employee. Now we have 6 remaining job, that we need to assign to 4 employee. why 4?
Because best employee still can do other jobs.
Let N(e2) denotes no. of function where e2 is not assigned to any job.
 this will represent the no. of functions where e2, e3 and e4 is assign to any job.

why we are not counting best employee for this counting because best employee is always assign to the job


Consider the following function

int BSR (int arr[ ], int k)


int val=0, i, last;


value +=arr[i];

last =(k*(k-1))/2;

return (value-last);


Assume that the array contains list of all numbers from 1 to k-1.What is return value of function BSR?


This program finds a repeated number (duplicate) in the list. This program adds all values in the variable “ value” and substract “k(k-1)2” from it.Array has 0 to (k-1) locations and numbers are from 1 to (k-1).so one number will be repeated in the array.


Assuming that a pointer take 4 bytes and the size of an integer is 2 bytes. What is the size of the *a in declaration: int (*a) [10][2] ?


When you dereference a pointer, it actually gives out the type of object being pointed. Hence, in this case it is int and the answer is 10 * 2 * 2 (integer size ) = 40


Consider the following logical inferences

(A) “If you have a current password, then you can log onto the network.”

“You have a current password.”

Inference: “You can log onto the network.”

(B) “If Sita to go school then Ram will go to school.”

“Sita doesn’t go to school”.

Inference: “Ram doesn’t go to school”

Which of the following is TRUE?


Inference A, is Modus Ponens.

Inference B, is false.

Let P = Sita go to school.

Q = Ram go to school.

For P →Q to be true.

If P is true then Q has to be true. (There is no other choice for Q).

But if P is false then Q can be anything (True or False). Still P →Q is true.

This is also known as "The fallacy of denying the antecedent".

P →Q


∴(Nothing can be concluded).


The complex number  z = log (3+4i) in the standard form is;


The given expression can be written in a+ib form as :

where r, θ are the magnitude and argument of z respectively.


Consider the following function.

Void rajkumar(int n)




for (i=0;i<n;i++)


x = dequeue(Q);

y = dequeue(Q);






What is the functionality of above function rajkumar?


The function prints first n fibbonacci numbers note that 0 and 1 are initially there in the queue. In every iteration of loop, sum of two queue items is enqueued and the front item is dequeued.


Consider the following graph.

Assume starting vertex is A. What is the cost of optimal tour by travelling salesperson using the dynamic programming?



How many bit strings of length 8 are possible that either start with a 1 or end with 00?


Total number of bit strings that start with two zeros (26) or end in a one 



Assume a matrix A[-5….+5][5…50]  is stored in a linear in row major order. Base address of A is 0 and each element takes 1 word. Find the location of A[–2] [50].


Loc[-2] [50] = Base address


= 0+3*46+45=183


What is the maximum number of Binary Search Trees possible with 6 nodes?


Number of BST with ‘n’ nodes is given by 2nCn/(n+1)

=>12C6/7 =132.


Which of the following statements is not correct for a square matrix A? (| A | ≠ 0)


if we get A2 = I →then it's know as  Involuntary Matrix

if we get A2 = A → then matrix is Idempotent Matrix


If A is a symmetric matrix, A-1 will also be a symmetric matrix


Which is the correct option that shows minimization of figure shown?


In this, we see that on b state, state 2 will go to state 1 with state 3 going to state 4 which further will go as state 1 and state 4 are in different set. Further, states 2 and 3 are different from each other. As state 4 goes to state 4 with state 3 goes to state 5 and state 4 which lies in different sets, hence state 3 and state 4 gets separated from each other. Further, state 2 goes to state 1 while state 4 goes to state 4 and to state 1. Further it is seen that state 2 and state 4 are separated from each other.

Further it is observed that as state 1 goes to state 3 placed on node a and further to state 2 which lies on node b as shown, hence the minimized DFA transitions are added from state 1 to state 3 on a while state 1 to state 2 on node b. Further as state 2 goes to state 1 on node b and state 3 goes to state 1 on node a, so minimized DFA transitions adds from state 2 to state 1 on node b and further state 3 to state 1 on node a.


Consider the relation  having tuples 200, 300 and 100 respectively. Estimate number of tuples in relation 



Consider the following code snippet:

Do(int w, int x)

Where w and x are any two positive integers. The call Do(30,do(30,90)) will return ;


Ternary operator has the following syntax:

exp 1 ? exp 2 : exp 3

if exp 1 is TRUE, then exp 2 is evaluated else exp 3 would be evaluated. Do(30,90)would return 0 and Do(30,0) would return 30.

Hence A) is the correct answer.


Let X ϵ {0, 1} and Y ϵ {0, 1} be two independent binary random variables. If P (X = 0) = p and P(Y = 0) = q, then P(X + Y ≥ 1) is equal to;



A key that is chosen by the database designer as the principal means of identifying entities within an entity set is called a;


An attribute or set of attributes which can be used to distinguish every tuple in a table is called a super key.A super key for which no proper subset is a super key is called candidate key.There can be many candidate keys for a table and the candidate key selected by the database designer to identify the tuples uniquely is called a primary key.


Which cardinality best describes relationship runs where all team has drag experiment to runs?


From the above cardinalities, we see that ratios like 1:1, 1:N, N:1 and N:M gives cardinality constraint or numeric restriction on possible relationships. From this, we see that the ratio 1:N relation is most comfortable to describe the constant of ER team.


Consider a binary max-heap implemented using an array. Which of the following array represent a binary max-heap?


Max heap is stored in the array such that

Arr[k]>=Arr[2k] and Arr[k]>=Arr[2k+1]

Where k is the index of the array such that 1<=k<=n/2, Arr[2k] is left child and Arr[2k+1] is right child. Option (c) is the only array which satisfies above condition.


Consider of the following propositional statements?

Which of them are not valid?


1 is false because for P →Q to be true.

If P is true then Q has to be true. (There is no other choice for Q).

But if P is false then Q can be anything (True or False). Still P → Q is true.

This is also known as "The fallacy of denying the antecedent".

P → Q


∴ (Nothing can be concluded).

2 is modus ponens so it is valid, similarly 3 is hypothetical syllogism, it is also valid.

4 is false because 


Consider the following graph:


Which one of the following cannot be the sequence of edges added, in that order, to a minimum spanning tree using Kruskal’s algorithm?


The edge (d-e) cannot be considered before (d-c) in Kruskal’s minimum spanning tree algorithm because Kruskal’s algorithm picks the edge with minimum weight from the current set of edges at each step.


Which of the following is illegal statement?


a) p is a function that takes an argument as an array of pointers to characters and returns a pointer to an integer.

b) p is a function that takes an argument as a pointer to a character array and returns an integer.

c) p is a pointer to a function that takes an argument as a pointer to a character and returns an integer.

d) This is an illegal statement.

Hence (d) is the correct answer


Consider two functional dependency set F and G: F={ A→B, B→C, C→A} and G= {A→BC, B→AC, AB→C, BC→A} which of the following is true?


Here, According to FD set F,

A+= {ABC}, B+= {ABC}, C+= {ABC}

According to FD set G,

A+= {ABC}, B+= {ABC}, C+= {C}

So, F covers G but G doesn’t covers F. Hence, option A is correct.


Which of the following statement is false?


(a)f(n)=n^2 logn(true)

(b) If the graph has no edges (True)

(c) In a DAG the strongly-connected components consist of single nodes. To compute them just

scan the array of nodes. (True)

(d) They form a tree but the nodes in this tree are only those nodes reachable by a path from ‘s’and there may be strictly less than ‘n’ such nodes, therefore the tree may have strictly less

than (n – 1) edges. (False)


There are x number of identical balls which are to be placed in y number of distinct buckets. If x>= ky (where k is a natural number greater than equal to 1), then in how many ways can you place the balls in the bucket with the condition that each bucket should contain at least k balls?


As there have to be at least k balls in each bag, so firstly put k balls in each bag i.e k*y balls. Balls remaining: x-ky

We can now apply balls and sticks method.

y bags= y variables, they need to equal to x-k*y, no restrictions on how many balls in each bag. We can make a equation out of this:

a1 + a2 + ... + ay = x- k*y

On solving it we get our answer:  (x-ky+y-1) C (y-1)

*Answer can only contain numeric values

A system that uses a two-level page table has 212 - byte pages and 36-bit virtual addresses. The first 8-bits of the address serve as the index into the first level page table.

The number of bits specify the second level index is ________?


12 bits is the answer

as it is given that page size is 212 Bytes, so 12 bits are needed to specify that offset. The number of bits specify the second level index is:

36 - (12 + 8)

= 36 - 20

= 16


Consider the following rec function.

rec(int x)


static int f;

if (x==1)






Find the value returned by rec(5).


Returning from x = 1 to 5 “f” value is updated being a static variable = 40 + 5 × 40 = 240.


What is the complexity of the efficient algorithm to construct a balanced BST from a given normal BST?


Most efficient solution would be to traverse given BST in inorder sequence and store in an array which takes O(n). Building a balanced BST from an array takes O(n). So complexity = O(n).


Consider the directed graph shown in the figure below. There are multiple shortest paths between vertices S and T. Which one will be reported by Dijkstra’s shortest path algorithm? Assume that, in any iteration, the shortest path to a vertex v is updated only when a strictly shorter path to v is discovered.



Consider the following table with 4 processes:

If the system is having 150 unit of resources, Identify the value of X and Y for which the system will not be safe?


For the system not to be in safe state, values should be distributed in such a way that remaining resources should not be able to satisfy the need of any of the process.

After Observing, it is clear that when X= 40 and Y=20 the remaining need of the processes can be listed as:

Remaining Resources= 150-140=10

And we cannot satisfy the need of any of the given process.

Hence option d is the correct answer.

Use Code STAYHOME200 and get INR 200 additional OFF
Use Coupon Code