PYQs
PYQs
PYQs
Operating System
(Topic-wise)
(https://www.youtube.com/playlist?list=PLqHw2_FIWUzZnh51IWUzHWmQ66YD
srH4i)
PROCESS & THREAD MANAGEMENT
Q1. In the following process state transition diagram for a uni-processor system,
assume that there are always some processes in the ready state: Now consider
the following statements:
The completion order of the 3 processes under the policies FCFS and RR2
(round robin scheduling with CPU quantum of 2 time units) are
(a) FCFS: P1, P2, P3 RR2: P1, P2, P3
(b) FCFS: P1, P3, P2 RR2: P1, P3, P2
(c) FCFS: P1, P2, P3 RR2: P1, P3, P2
(d) FCFS: P1, P3, P2 RR2: P1, P2, P3 [Marks:2][GATE: 2012]
Q8. A scheduling algorithm assigns priority proportional to the waiting time of a
process. Every process starts with priority zero (the lowest priority). The
scheduler re-evaluates the process priorities every T time units and decides the
next process to schedule. Which one of the following is TRUE if the processes
have no I/O operations and all arrive at time zero?
(a) This algorithm is equivalent to the first-come-first-serve algorithm
(b) This algorithm is equivalent to the round-robin algorithm.
(c) This algorithm is equivalent to the shortest-job-first algorithm..
(d) This algorithm is equivalent to the shortest-remaining-time-first algorithm
[Marks:1][GATE: 2013]
Q9. Which one of the following is FALSE?
(a) User level threads are not scheduled by the kernel.
(b) When a user level thread is blocked, all other threads of its process are
blocked.
(c) Context switching between user level threads is faster than context
switching between kernel level threads.
(d) Kernel level threads cannot share the code segment.
[Marks: 1][GATE: 2014][SET-1]
Q10. Consider the following set of processes that need to be scheduled on a single
CPU. All the times are given in milliseconds.
Using the shortest remaining time first scheduling algorithm, the average
process turnaround time (in msec) is _______________.
[Marks: 2][GATE: 2014][SET-1]
Q11. Three processes A, B and C each execute a loop of 100 iterations. In each
iteration of the loop, a process performs a single computation that requires
tc CPU milliseconds and then initiates a single I/O operation that lasts for t io
milliseconds. It is assumed that the computer where the processes execute
has sufficient number of I/O devices and the OS of the computer assigns
different I/O devices to each process. Also, the scheduling overhead of the
OS is negligible. The processes have the following characteristics:
Process id tc tio
A 100 ms 500 ms
B 350 ms 500 ms
C 200 ms 500 ms
The processes A, B, and C are started at times 0, 5 and 10 milliseconds
respectively, in a pure time sharing system (round robin scheduling) that
uses a time slice of 50 milliseconds. The time in milliseconds at which process
C would complete its first I/O operation is ___________.
[Marks: 2][GATE: 2014][SET-2]
Q12. An operating system uses shortest remaining time first scheduling algorithm
for pre-emptive scheduling of processes. Consider the following set of
processes with their arrival times and CPU burst times (in milliseconds):
The
average waiting time (in milliseconds) of the processes is _________.
[Marks: 2][GATE: 2014][SET-3]
Q13. Consider a uniprocessor system executing three tasks T1, T2 and T3, each
of which is composed of an infinite sequence of jobs (or instances) which
arrive periodically at intervals of 3, 7 and 20 milliseconds, respectively. The
priority of each task is the inverse of its period and the available tasks are
scheduled in order of priority, with the highest priority task scheduled first.
Each instance of T1, T2 and T3 requires an execution time of 1, 2 and 4
milliseconds, respectively. Given that all tasks initially arrive at the beginning
of the 1st milliseconds and task preemptions are allowed, the first instance
of T3 completes its execution at the end of ______________ milliseconds.
Q16. Consider an arbitrary set of CPU-bound processes with unequal CPU burst
lengths submitted at the same time to a computer system. Which one of the
following process scheduling algorithms would minimize the average waiting
time in the ready queue?
(a) Shortest remaining time first
(b) Round-robin with time quantum less than the shortest CPU burst
(c) Uniform random
(d) Highest priority first with priority proportional to CPU burst length
[Marks: 1][GATE: 2016][SET-1]
Q17. Consider the following processes, with the arrival time and the length of the
CPU burst given in milliseconds. The scheduling algorithm used is
preemptive shortest remaining-time first.
The average waiting time (in milliseconds) of all the processes using preemptive
priority scheduling algorithm is __________.
[Marks: 2][GATE: 2017][SET-2]
Q22. The following C program is executed on a Unix/Linux system
#include <unistd.h>
int main ()
{
int i;
for(i = 0; i < 10; i++)
if (i%2 == 0) fork ();
return 0;
}
The total number of child processes created is _________.
[Marks: 1][GATE:2019]
Q23. The following C program is executed on a Unix/Linux system
#include <unistd.h>
int main ()
{
int i;
for(i = 0; i < 10; i++)
if (i%2 == 0) fork ();
return 0;
}
The total number of child processes created is _________.
[Marks: 1][GATE:2019]
Q24. Consider the following statements about process state transitions for a system
using preemptive scheduling.
I. A running process can move to ready state.
II. A ready process can move to running state.
III. A blocked process can move to running state.
IV. A blocked process can move to ready state.
Which of the above statements are TRUE?
(a) II and III only (b) I, II and III only
(c) I, II, III and IV (d) I, II and IV only
[Marks:1][GATE:2020]
Q25. RR, assume that the processes are scheduled in the order P1, P2, P3, P4.
If the time quantum for RR is 4 ms, then the absolute value of the difference
between the average turnaround times (in ms) of SJF and RR (round off to 2
decimal places) is _________. [Marks: 1][GATE: 2020]
DEADLOCK
Q1. Consider a system with 4 types of resources R1 (3 units), R2 (2 units), R3 (3
units), R4 (2 units). A non-preemptive resource allocation policy is used. At any
given instance, a request is not entertained if it cannot be completely satisfied.
Three processes P1, P2, P3 request the sources as follows if executed
independently.
Process P1: Process P2: Process P3:
t=0: requests 2 units of R2 t=0: requests 2 units of R3 t=0: requests 1 unit of R4
t=1: requests 1 unit of R3 t=2: requests 1 unit of R4 t=2: requests 2 units of R1
t=3: requests 2 units of R1 t=4: requests 1 unit of R1 t=5: releases 2 units of R1
t=5: releases 1 unit of R2 t=6: releases 1 unit of R3 t=7: requests 1 unit of R2
and 1 unit of R1. t=8: Finishes t=8: requests 1 unit of R3
t=7: releases 1 unit of R3 t=9: Finishes
t=8: requests 2 units of R4
t=10: Finishes
Q16. Each of a set of n processes
PROCESS executes
SYNCHRONIZATION
the following code using two semaphores
a and
Q1. The b initialized
enter_CS () and to 1 and 0,
leave_CS () respectively.
functions to Assume thatcritical
implement count section
is a shared
of a
variable
process initialized
are realized to 0 and
using not used in
test-and-set CODE SECTION
instruction P.
as follows:
voidCODEenter_CS(X)
SECTION P
{wait (a); count = count + 1;
while (test-and-set(X));
if
} (count == n) signal (b);
signal
void (a); wait (b); signal (b);
leave_CS(X)
{ CODE SECTION Q
X=0;
What does the code achieve?
}
In(a)the
It ensures that all processes
above solution, executelocation
X is a memory CODE SECTION P mutually
associated with the exclusively
CS and is
(b) It ensures
initialized to 0. that
Now at most two
consider theprocesses
following are in CODE SECTION Q at any time.
statements:
I. (c) ItThe
ensures
abovethat no process
solution to CS executes CODE
problem is SECTION Q before every process
deadlock-free
II. has
Thefinished
solutionCODE SECTION
is starvation P
free.
(d) ItThe
III. ensures that at
processes mostCS
enter n-1
in processes
FIFO are in CODE SECTION P at any time.
IV. More than one process can enter CS at the same [Marks:
time. 2][GATE: 2020].
Which of the above statements is TRUE?
(a) I only
(b) I and II
(c) II and III
(d) IV only
[Marks: ][GATE: 2009]
Q2. Consider the methods used by processes P1 and P2 for accessing their critical
sections whenever needed, as given below. The initial values of shared Boolean
variables S1 and S2 are randomly assigned.
Method used by P1 Method used by P2
While (S1 == S2); While (S1 != S2);
Critical Section Critical Section
S1= S2; S2 = not (S1)
While one of the following statements describes properties achieved?
(a) Mutual exclusion but not progress
(b) Progress but not mutual exclusion
(c) Neither mutual exclusion nor progress
(d) Both mutual exclusion and progress
[Marks: 1][GATE: 2010]
Q3. The following program consists of 3 concurrent processes and 3 binary
semaphores. The semaphores are initialized as S0 = 1, S1 = 0, S2 = 0:
The number of distinct values that B can possibly take after the execution is
(a) 3
(b) 2
(c) 5
(d) 4
[Marks: 1][GATE: 2015][SET-1]
Two processes X and Y need to access a critical section. Consider the following
Q10.
synchronization construct used by both the processes.
Here, varP and varQ are shared variables and both are initialized to false. Which
one of the following statements is true?
(A) The proposed solution prevents deadlock but fails to guarantee mutual
exclusion
(B) The proposed solution guarantees mutual exclusion but fails to prevent
deadlock
(C) The proposed solution guarantees mutual exclusion and prevents deadlock
(D) The proposed solution fails to prevent deadlock and fails to guarantee mutual
exclusion
[Marks:1][GATE: 2015][SET-3]
Which one of the following statements is TRUE if all three processes run
concurrently starting at time t=0?
(a) All processes will finish without any deadlock
Q11. Consider the following proposed solution for the critical section problem. There
are n processes: P0…Pn−1. In the code, function pmax returns an integer not
smaller than any of its arguments. For all i, t[i] is initialized to zero.
Code for Pi:
do {
c[i] = 1; t[i] = pmax(t[0],...,t[n-1])+1; c[i]=0;
for every j ≠ i in {0,...,n-1} {
while (c[j]);
while (t[j] != 0 && t[j] <= t[i]);
}
Critical Section;
t[i] = 0;
Remainder Section;
} while (true);
Which one of the following is TRUE about the above solution?
(a) At most one process can be in the critical section at any time
(b) The bounded wait condition is satisfied
(c) The progress condition is satisfied
(d) It cannot cause a deadlock
[Marks: 2][GATE: 2016][SET-1]
Q12. Consider the following two-process synchronization solution.
Process 0 Process 1
Entry: loop while (turn == 1); Entry: loop while (turn == 0);
(critical section) (critical section)
Exit: turn = 1; Exit: turn = 0;
The shared variable turn is initialized to zero. Which one of the following is
TRUE?
(a) This is a correct two-process synchronization solution.
(b) This solution violates mutual exclusion requirement.
(c) This solution violates progress requirement.
(d) This solution violates bounded wait requirement.
[Marks: 2][GATE: 2016][SET-2]
Which one of the following assignments to P, Q, R and S will yield the correct
solution?
(a) P: full, Q: full, R: empty, S: empty
(b) P: empty, Q: empty, R: full, S: full
(c) P: full, Q: empty, R: empty, S: full
(d) P: empty, Q: full, R: full, S: empty
[Marks: 2][GATE: 2018]
Q15. Consider three concurrent processes P1, P2 and P3 as shown below, which
access a shared variable D that has been initialized to 100.
Which of the following best describes the current state of the system?
(a) Safe, Deadlocked
(b) Safe, Not Deadlocked
(c) Not Safe, Deadlocked
(d) Not Safe, Not Deadlocked
[Marks: 2][GATE: 2017][SET-2]
Q9. In a system, there are three types of resources: E, F and G. Four processes P0,
P1, P2 and P3 execute concurrently. At the outset, the processes have declared
their maximum resource requirements using a matrix named Max as given
below. For example, Max [P2, F] is the maximum number of instances of F that
P2 would require. The number of instances of the resources allocated to the
various processes at any given state is given by a matrix named
Allocation.Consider a state of the system with the Allocation matrix as shown
below, and in which 3 instances of E and 3 instances of F are the only resources
available.
From the perspective of deadlock avoidance, which one of the following is true?
(a) The system is in safe state
(b) The system is not in safe state, but would be safe if one more instance of
E were available
(c) The system is not in safe state, but would be safe if one more instance of
F were available
(d) The system is not in safe state, but would be safe if one more instance of
G were available
[Marks: 2][GATE: 2018]
Q10. Consider a system with 3 processes that share 4 instances of the same resource
type. Each process can request a maximum of K instances. Resource instances
can be requested and released only one at a time. The largest value of K that
will always avoid deadlock is _______. [Marks:1][GATE: 2018]
Q11. Consider the following snapshot of a system running n concurrent processes.
Process i is holding Xi instances of a resource R, 1 ≤ i ≤ n. Assume that all
instances of R are currently in use. Further, for all i, process i can place a
request for at most Yi additional instances of R while holding the Xt instances
it already has. Of the n processes, there are exactly two processes p and q
such that Yp = Yq = 0. Which one of the following conditions guarantees that
no other process apart from p and q can complete execution?
(a)Min (Xp, Xq) ≥ Min {Yk | 1 ≤ k ≤ n, k ≠ p, k ≠ q}
(b)Xp + Xq< Max {Yk | 1 ≤ k ≤ n, k ≠ p, k ≠ q}
(c)Min (Xp, Xq) ≤ Max {Yk | 1 ≤ k ≤ n, k ≠ p, k ≠ q}
(d)Xp + Xq< Min {Yk | 1 ≤ k ≤ n, k ≠ p, k ≠ q}
[Marks: 2][GATE:2019]
MEMORY MANAGEMENT
Q1. In which one of the following page replacement policies, Belady’s anomaly may
occur?
(a) FIFO (b) Optimal (c) LRU (d)
MRU
[Marks: 1][GATE: 2009]
Q2. The essential content(s) in each entry of a page table is / are.
(a) Virtual page number
(b) Page frame number
(c) Both virtual page number and page frame number
(d) Access right information [Marks: 1][GATE: 2009]
Q3. A multilevel page table is preferred in comparison to a single level page table
for translating virtual address to physical address because
(a) It reduces the memory access time to read or write a memory location.
(b) It helps to reduce the size of page table needed to implement the virtual
address space of a process.
(c) It is required by the translation look aside buffer.
(d) It helps to reduce the number of page faults in page replacement
algorithms
[Marks: ][GATE: 2009]
Q4. A system uses FIFO policy for page replacement. It has 4 page frames with no
pages loaded to begin with. The system first accesses 100 distinct pages in
some order and then access the same 100 pages but now in the reverse order.
How many page faults will occur?________
(a) 196
(b) 192
(c) 197
(d) 195 [Marks: 1][GATE:2010]
Q5. Let the page fault service time be 10ms in a computer with average memory
access time being 20ns. If one page fault is generated for every 10^6 memory
accesses, what is the effective access time for the memory?
(a) 21ns
(b) 30ns
(c) 23ns
(d) 35ns [Marks: 1][GATE: 2011]
Q6. Consider the virtual page reference string
1, 2, 3, 2, 4, 1, 3, 2, 4, 1
On a demand paged virtual memory system running on a computer system that
main memory size of 3 pages frames which are initially empty. Let LRU, FIFO
and OPTIMAL denote the number of page faults under the corresponding page
replacements policy. Then
(a) OPTIMAL < LRU < FIFO (b) OPTIMAL < FIFO < LRU
(c) OPTIMAL = LRU (d) OPTIMAL = FIFO
[Marks: 2][GATE: 2012]
Q7. A computer uses 46-bit virtual address, 32-bit physical address, and a three-
level paged page table organization. The page table base register stores the base
address of the first-level table (T1), which occupies exactly one page. Each entry
of T1 stores the base address of a page of the second-level table (T2). Each entry
of T2 stores the base address of a page of the third-level table (T3). Each entry
of T3 stores a page table entry (PTE). The PTE is 32 bits in size. The processor
used in the computer has a 1 MB 16-way set associative virtually indexed
physically tagged cache. The cache block size is 64 bytes. What is the size of a
page in KB in this computer?
(a) 2 (b) 4 (c) 8 (d) 16
[Marks:2][GATE: 2013]
Q8. A computer uses 46-bit virtual address, 32-bit physical address, and a three-
level paged page table organization. The page table base register stores the base
address of the first-level table (T1), which occupies exactly one page. Each entry
of T1 stores the base address of a page of the second-level table (T2). Each entry
of T2 stores the base address of a page of the third-level table (T3). Each entry
of T3 stores a page table entry (PTE). The PTE is 32 bits in size. The processor
used in the computer has a 1 MB 16-way set associative virtually indexed
physically tagged cache. The cache block size is 64 bytes. Consider the same
data as above question. What is the minimum number of page colors needed to
guarantee that no two synonyms map to different sets in the processor cache
of this computer?
(a) 2 (b) 4 (c) 8 (d) 16
[Marks: 2][GATE: 2013]
Q9. Assume that there are 3 page frames which are initially empty. If the page
reference string is 1, 2, 3, 4, 2, 1, 5, 3, 2, 4, 6, the number of page faults using
the optimal replacement policy is__________.
[Marks: 2][GATE: 2014][SET-1]
Q10. A computer has twenty physical page frames which contain pages numbered
101 through 120. Now a program accesses the pages numbered 1, 2, …, 100
in that order, and repeats the access sequence THRICE. Which one of the
following page replacement policies experiences the same number of page faults
as the optimal page replacement policy for this program?
(a) Least-recently-used
(b) First-in-first-out
(c) Last-in-first-out
(d) Most-recently-used
[Marks:2][GATE: 2014][SET-2]
Q11. A system uses 3 page frames for storing process pages in main memory. It uses
the Least Recently Used (LRU) page replacement policy. Assume that all the
page frames are initially empty. What is the total number of page faults that
will occur while processing the page reference string given below?
4, 7, 6, 1, 7, 6, 1, 2, 7, 2
(a) 4 (b) 5 (c) 6 (d) 7
[Marks: 2][GATE: 2014][SET-2]
Q12. Consider a paging hardware with a TLB. Assume that the entire page table and
all the pages are in the physical memory. It takes 10 milliseconds to search the
TLB and 80 milliseconds to access the physical memory. If the TLB hit ratio is
0.6, the effective memory access time (in milliseconds) is _________.
[Marks: 2][GATE: 2014][SET-3]
Q14. Consider a main memory with five page frames and the following sequence of
page references: 3, 8, 2, 3, 9, 1, 6, 3, 8, 9, 3, 6, 2, 1, 3. Which one of the
following is true with respect to page replacement policies First-In-First Out
(FIFO) and Least Recently Used (LRU)?
(a) Both incur the same number of page faults
(b) FIFO incurs 2 more page faults than LRU
(c) LRU incurs 2 more page faults than FIFO
(d) FIFO incurs 1 more page faults than LRU[Marks: 2][GATE: 2015][SET-1]
Q15. A computer system implements a 40 bit virtual address, page size of 8 kilobytes,
and a 128-entry translation look-aside buffer (TLB) organized into 32 sets each
having four ways. Assume that the TLB tag does not store any process id. The
minimum length of the TLB tag in bits is _________
[Marks: 1][GATE: 2015][SET-2]
Q16. Consider six memory partitions of size 200 KB, 400 KB, 600 KB, 500 KB, 300
KB, and 250 KB, where KB refers to kilobyte. These partitions need to be
allotted to four processes of sizes 357 KB, 210 KB, 468 KB and 491 KB in that
order. If the best fit algorithm is used, which partitions are NOT allotted to any
process?
(a) 200 KB and 300 KB
(b) 200 KB and 250 KB
(c) 250 KB and 300 KB
(d) 300 KB and 400 KB
[Marks: 2][GATE: 2015][SET-2]
Q17. A Computer system implements 8 kilobyte pages and a 32-bit physical address
space. Each page table entry contains a valid bit, a dirty bit three permission
bits, and the translation. If the maximum size of the page table of a process is
24 megabytes, the length of the virtual address supported by the system is
_______________bits
(a) 36 (b) 32 (c) 28 (d) 40
[Marks:2][GATE: 2015][SET-
2]
Q18. Consider a computer system with 40-bit virtual addressing and page size of
sixteen kilobytes. If the computer system has a one-level page table per process
and each page table entry requires 48 bits, then the size of the per-process page
table is __________________megabytes.
[Marks: 2][GATE: 2016][SET-1]
Q19. Consider a computer system with ten physical page frames. The system is
provided with an access sequence (a1, a2, ..., a20, a1, a2, ..., a20), where each
ai is a distinct virtual page number. The difference in the number of page faults
between the last-in-first-out page replacement policy and the optimal page
replacement policy is______________[Marks: 2][GATE: 2016][SET-1]
Q20. In which one of the following page replacement algorithms it is possible for the
page fault rate to increase even when the number of allocated frames increases?
(a) LRU (Least Recently Used)
(b) OPT (Optimal Page Replacement)
(c) MRU (Most Recently Used)
(d) FIFO (First In First Out)
[Marks: 1][GATE: 2016][SET-2]
Q21. Recall that Belady's anomaly is that the page-fault rate may increase as the
number of allocated frames increases. Now, consider the following statements:
S1: Random page replacement algorithm (where a page chosen at random is
replaced) suffers from Belady’s anomaly.
S2: LRU page replacement algorithm suffers from Belady’s anomaly.
(a) S1 is true, S2 is true
(b) S1 is true, S2 is false
(c) S1 is false, S2 is true
(d) S1 is false, S2 is false
[Marks: 2][GATE: 2017][SET-1]
Q22. Consider a process executing on an operating system that uses demand paging.
The average time for a memory access in the system is M units if the
corresponding memory page is available in memory, and D units if the memory
access causes a page fault. It has been experimentally measured that the
average time taken for a memory access in the process is X units. Which one
of the following is the correct expression for the page fault rate experienced by
the process?
(a) (D – M) / (X – M) (b) (X – M) / (D – M)
(c) (D – X) / (D – M) (d) (X – M) / (D – X)
[Marks: 1][GATE: 2018]
Q23. Assume that in a certain computer, the virtual addresses are 64 bits long and
the physical addresses are 48 bits long. The memory is word addressable. The
page size is 8KB and the word size is 4 bytes. The Translation Look-aside
Buffer (TLB) in the address translation path has 128 valid entries. At most
how many distinct virtual addresses can be translated without any TLB miss?
(a)16 x 210 (b) 256 x 210 (c) 4 x 220 (d) 8 x 220
[Marks:2][GATE:2019]
Q24. Consider allocation of memory to a new process. Assume that none of the
existing holes in the memory will exactly fit the process’s memory requirement.
Hence, a new hole of smaller size will be created if allocation is made in any of
the existing holes. Which one of the following statements is TRUE?
(a) The hole created by worst fit is always larger than the hole created by first
fit.
(b) The hole created by best fit is never larger than the hole created by first fit.
(c) The hole created by first fit is always larger than the hole created by next fit.
(d) The hole created by next fit is never larger than the hole created by best fit.
[Marks: 1][GATE: 2020]
Q25. Consider a paging system that uses a 1-level page table residing in main
memory and a TLB for address translation. Each main memory access takes
100 ns and TLB lookup takes 20 ns. Each page transfer to/from the disk takes
5000 ns. Assume that the TLB hit ratio is 95%, page fault rate is 10%. Assume
that for 20% of the total page faults, a dirty page has to be written back to disk
before the required page is read in from disk. TLB update time is negligible. The
average memory access time in ns (round off to 1 decimal places) is _________.
[Marks: 2][GATE: 2020]
File System And Disk Scheduling
Q1. Consider a disk system with 100 cylinders. The requests to access the cylinders
occur in following sequence: 4, 34, 10, 7, 19, 73, 2, 15, 6, 20 Assuming that
the head is currently at cylinder 50, what is the time taken to satisfy all
requests if it takes 1ms to move from one cylinder to adjacent one and shortest
seek time first policy is used?
(a) 95 ms (b)119 ms (c)233 ms (d) 276 ms
[Marks: 2][GATE: 2009]
Q2. A file system with 300 Gbytes disk uses a file descriptor with 8 direct block
addresses, 1 indirect block address and 1 doubly indirect block address. The
size of each disk block is 128 Bytes and the size of each disk block address is
8 Bytes. The maximum possible file size in this file system is
(a) 3 Kbytes (b) 35 Kbytes
(c) 280 Bytes (d) Dependent on the size of the disk
[Marks: 2][GATE: 2012]
Q3. Suppose a disk has 201 cylinders, numbered from 0 to 200. At some time the
disk arm is at cylinder 100, and there is a queue of disk access requests for
cylinders 30, 85, 90, 100, 105, 110, 135 and 145. If Shortest-Seek Time First
(SSTF) is being used for scheduling the disk access, the request for cylinder 90
is serviced after servicing ____________ number of requests.
[Marks: 1][GATE: 2014][SET-1]
Q4. A FAT (file allocation table) based file system is being used and the total
overhead of each entry in the FAT is 4 bytes in size. Given a 100×106 bytes disk
on which the file system is stored and data block size is 103 bytes, the
maximum size of a file that can be stored on this disk in units of 106 bytes is
_________.
[Marks:1][GATE: 2014][SET-2]
Q5. Suppose the following disk request sequence (track numbers) for a disk with
100 tracks is given: 45, 20, 90, 10, 50, 60, 80, 25, 70. Assume that the initial
position of the R/W head is on track 50. The additional distance that will be
traversed by the R/W head when the Shortest Seek Time First (SSTF) algorithm
is used compared to the SCAN (Elevator) algorithm (assuming that SCAN
algorithm moves towards 100 when it starts execution) is _________ tracks
[Marks: 2][GATE: 2015][SET-1]
Q6. Consider a disk queue with requests for I/O to blocks on cylinders 47, 38, 121,
191, 87, 11, 92, 10. The C-LOOK scheduling algorithm is used. The head is
initially at cylinder number 63, moving towards larger cylinder numbers on its
servicing pass. The cylinders are numbered from 0 to 199. The total head
movement (in number of cylinders) incurred while servicing these requests
is:____________
[Marks: 2][GATE: 2016][SET-1]
Q7. In a file allocation system, which of the following allocation scheme(s) can be
used if no external fragmentation is allowed?
I. Contiguous II. Linked III. Indexed
(a) I and III only
(b) II only
(c) III only
(d) II and III only [Marks: 1][GATE: 2017][SET-
2]
Q8. Consider a storage disk with 4 platters (numbered as 0, 1, 2 and 3), 200
cylinders (numbered as 0, 1, … , 199), and 256 sectors per track (numbered as
0, 1, … 255). The following 6 disk requests of the form [sector number, cylinder
number, platter number] are received by the disk controller at the same time:
[120, 72, 2], [180, 134, 1], [60, 20, 0], [212, 86, 3], [56, 116, 2], [118, 16, 1]
Currently head is positioned at sector number 100 of cylinder 80, and is moving
towards higher cylinder numbers. The average power dissipation in moving the
head over 100 cylinders is 20 milliwatts and for reversing the direction of the
head movement once is 15 milliwatts. Power dissipation associated with
rotational latency and switching of head between different platters is negligible.
The total power consumption in milliwatts to satisfy all of the above disk
requests using the Shortest Seek Time First disk scheduling algorithm is ______
[Marks: 2][GATE: 2018]
Q9. The index node (Inode) of a Unix-like file system has 12 direct, one single-
indirect and one double-indirect pointer. The disk block size is 4 kB and the
disk block addresses 32-bits long. The maximum possible file size is (rounded
off to 1 decimal place) __________ GB.
[Marks: 2][GATE:2019]
Q10. Consider the following five disk access requests of the form (request id, cylinder
number) that are present in the disk scheduler queue at a given time.
(P, 155), (Q, 85), (R, 110), (S, 30), (T, 115)
Assume the head is positioned at cylinder 100. The scheduler follows Shortest
Seek Time First scheduling to service the requests. Which one of the following
statements is FALSE?
(a) The head reverses its direction of movement between servicing of Q and P.
(b) T is serviced before P.
(c) R is serviced before P.
(d) Q is serviced after S, but before T.
[Marks: 2][GATE: 2020]
Operating System
PROCESS & THREAD MANAGEMENT
1. C 2. D 3. C 4. C 5. A
6. C 7. C 8. B 9. D 10. 7.2
PROCESS SYNCHRONIZATION
1. A 2. A 3. A 4. B 5. B
6. C 7. D 8. C 9. A 10. A
16. C
DEADLOCK
1. A 2. B 3. B 4. B 5. D
6. D 7. D 8. B 9. A 10. 2
11. D
MEMORY MANAGEMENT
1. A 2. B 3. B 4. A 5. B
6. B 7. C 8. C 9. 7 10. D
Computer Network
(Topic-wise)
Q2. A bit-stuffing based framing protocol uses an 8-bit delimiter pattern of 01111110.
If the output bit-string after stuffing is 01111100101, then the input bit-string is
(a) 0111110100 (b) 0111110101
(c) 0111111101 (d) 0111111111
[Marks: 2 ][GATE:2014][SET-3]
Q3. A computer network uses polynomials over GF (2) for error checking with 8 bits as
information bits and uses x3 + x + 1 as the generator polynomial to generate the
check bits. In this network, the message 01011011 is transmitted as
(a)01011011010
(b)01011011011
(c)01011011101
(d) 01011011100
[Marks: 1][GATE: 2017][SET-1]
Q4. Consider a binary code that consist only four valid code words as given below.
00000, 01011, 10101, 11110
Let minimum Hamming distance of code be p and maximum number of erroneous
bits that can be corrected by the code be q. The value of p and q are:
(a) p = 3 and q = 1
(b) p = 3 and q = 2
(c) p = 4 and q = 1
(d) p = 4 and q = 2
[Marks: 2][GATE: 2017][SET-2]
Q5. A link has a transmission speed of 106 bits/sec. It uses data packets of size 1000
bytes each. Assume that the acknowledgment has negligible transmission delay,
and that its propagation delay is the same as the data propagation delay. Also
assume that the processing delays at nodes are negligible. The efficiency of the
stop-and-wait protocol in this setup is exactly 25%. The value of the one-way
propagation delay (in milliseconds) is ___________.[Marks: 1][GATE: 2015][SET-2]
Q6. Consider a network connecting two systems located 8000 kilometers apart. The
bandwidth of the network is 500 × 10^6 bits per second. The propagation speed of
the media is 4 × 10^6 meters per second. It is needed to design a Go-Back-N sliding
window protocol for this network. The average packet size is 10^7 bits. The
network is to be used to its full capacity. Assume that processing delays at nodes
are negligible. Then, the minimum size in bits of the sequence number field has to
be ___________.
[Marks: 2][GATE: 2015][]SET-3]
Q7. A sender uses the Stop-and-Wait ARQ protocol for reliable transmission of frames.
Frames are of size 1000 bytes and the transmission rate at the sender is 80 Kbps
(1Kbps = 1000 bits/second). Size of an acknowledgement is 100 bytes and the
transmission rate at the receiver is 8 Kbps. The one-way propagation delay is 100
milliseconds. Assuming no frame is lost, the sender throughput is __________
bytes/second.
[Marks: 2 ][GATE: 2016][SET-1]
Q8. Consider a 128×10 bits/second satellite communication link with one-way
3
All the routers use the distance vector based routing algorithm to update their
routing tables. Each starts with its routing table initialized to contain an entry for
each neighbour with the weight of the respective connecting link. After all the
routing tables stabilize, how many links in the network will never be used for
carrying any?
Data?
(a) 4 (b) 3
(c) 2 (d) 1
Q4. Mark: 2 GATE: 2010
Consider a network with 6 routers R1 and R6 connected with links Having weights
as shown in the following diagram
Suppose the weights of all unused links in the previous question are changed to 2
and the distance vector algorithm is used again until all routing tables stabilize.
How many links will now remain unused?
(a) 0
(b) 1
(c) 2
(d) 3
Q5. Mark:2 GATE: 2011
Consider a network with five nodes, N1 to N5, as shown below.
The network uses a Distance Vector Routing protocol. Once the routes have
stabilized, the distance vectors at different nodes are as following.
N1: (0, 1, 7, 8, 4)
N2: (1, 0, 6, 7, 3)
N3: (7, 6, 0, 2, 6)
N4: (8, 7, 2, 0, 4)
N5: (4, 3, 6, 4, 0)
Each distance vector is the distance of the best known path at the instance to
nodes, N1 to N5, where the distance to itself is 0. Also, all links are symmetric and
the cost is identical in both directions. In each round, all nodes exchange their
distance vectors with their respective neighbors. Then all nodes update their
distance vectors. In between two rounds, any change in cost of a link will cause
the two incident nodes to change only that entry in their distance vectors. The cost
of link N2-N3 reduces to 2 (in both directions). After the next round of updates,
what will be the new distance vector at node, N3?
(a) (3, 2, 0, 2, 5) (b) (3, 2, 0, 2, 6)
(c) (7, 2, 0, 2, 5) (d) (7, 2, 0, 2, 6)
Q6. Mark:2 GATE: 2011
Consider a network with five nodes, N1 to N5, as shown below.
The network uses a Distance Vector Routing protocol. Once the routes have
stabilized, the distance vectors at different nodes are as following.
N1: (0, 1, 7, 8, 4)
N2: (1, 0, 6, 7, 3)
N3: (7, 6, 0, 2, 6)
N4: (8, 7, 2, 0, 4)
N5: (4, 3, 6, 4, 0)
Each distance vector is the distance of the best known path at the instance to
nodes, N1 to N5, where the distance to itself is 0. Also, all links are symmetric and
the cost is identical in both directions. In each round, all nodes exchange their
distance vectors with their respective neighbors. Then all nodes update their
distance vectors. In between two rounds, any change in cost of a link will cause
the two incident nodes to change only that entry in their distance vectors. After the
update in the previous question, the link N1-N2 goes down. N2 will reflect this
change immediately in its distance vector as cost, infinite. After the NEXT ROUND
of update, what will be cost to N1 in the distance vector of N3?
(a) 3
(b) 9
(c) 10
(d) Infinite
Q7. Mark:1 GATE: 2012
In the IPv4 addressing format, the number of networks allowed under Class C
addresses is
(a) 2 14 (b) 2 7 (c) 2 21 (d) 2 24
Q8. Mark:2 GATE: 2012
Consider a source computer(S) transmitting a file of size 106 bits to a destination
computer(D)over a network of two routers (R1 and R2) and three links(L1, L2, and
L3). L1connects S to R1; L2 connects R1 to R2; and L3 connects R2 to D. Let each
link be of length 100 km. Assume signals travel over each link at a speed of 108
meters per second. Assume that the link bandwidth on each link is 1Mbps. Let the
file be broken down into 1000 packets each of size 1000 bits. Find the total sum
of transmission and propagation delays in transmitting the file from S to D?
(a) 1005 ms
(b) 1010 ms
(c) 3000 ms
(d) 3003 ms
Q9. Mark:2 GATE: 2012
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/24 and 245.248.132.0/21
For each IP address in Group-I identify the correct choice of the next hop from
Group-II Using the entries from the routing table above.
Computer Network
DATA LINK LAYER ERROR CONTROL
1. C 2. B 3. C 4. A
6. C 7. C 8. A 9. A 10. C
31. D 32. B
TRANSPORT LAYER
1. A 2. C 3. 1100 4. C 5. B
6. B 7. c 8. a 9. d 10. b
APPLICATION LAYER
1. D 2. c 3. d 4. c 5. c
6. c 7. c 8. c 9. a 10. c
11. c 12. c 13. b 14. 6
GATE Computer Science & IT
Computer Organization
And Architecture
(Topic-wise)
PYQ Questions Booklet
(https://www.youtube.com/playlist?list=PLqHw2_FIWUzaIFXymuruZI4CuVpc73
5es)
Cache Organization
Q1. Consider a 4-way set associative cache (initially empty) with total 16 cache
blocks. The main memory consists of 256 blocks and the request for memory
blocks is in the following order: 0, 255, 1, 4, 3, 8, 133, 159, 216, 129, 63, 8,
48, 32, 73, 92, and 155. Which one of the following memory block will NOT be
in cache if LRU replacement policy is used?
(a) 3 (b) 8 (c) 129 (d)
216
[Marks: ][GATE: 2009]
Q2. A computer system has an L1 cache, an L2 cache, and a main memory unit
connected as shown below. The block size in L1 cache is 4 words. The block
size in L2 cache is 16 words. The memory access times are 2 nanoseconds, 20
nanoseconds and 200 nanoseconds for L1 cache, L2 cache and main memory
unit respectively.
When there is a miss in both L1 cache and L2 cache, first a block is transferred
from main memory to L2 cache, and then a block is transferred from L2 cache
to L1 cache. What is the total time taken for these transfers?
(a) 222 nanoseconds
(b) 888 nanoseconds
(c) 902 nanoseconds
(d) 968 nanoseconds
[Marks: 2][GATE: 2010]
Q4. An 8KB direct-mapped write-back cache is organized as multiple blocks, each
of size 32-bytes. The processor generates 32-bit addresses. The cache
controller maintains the tag information for each cache block comprising of
the following.
1 Valid bit
1 Modified bit
As many bits as the minimum needed to identify the memory block mapped
in the cache. What is the total size of memory needed at the cache controller
to store meta-data (tags) for the cache?
(a) 4864 bits (b) 6144 bits (c) 6656 bits (d) 5376 bits
[Marks: 2][GATE: 2011]
Q5. A computer has a 256 Kbyte, 4-way set associative, write back data cache with
block size of 32 Bytes. The processor sends 32 bit addresses to the cache
controller. Each cache tag directory entry contains, in addition to address tag,
2 valid bits, 1 modified bit and 1 replacement bit. The number of bits in the
tag field of an address is
(a) 11 (b) 14 (c) 16 (d) 27
[Marks: 2 ][GATE: 2012]
Q6. A computer has a 256 Kbyte, 4-way set associative, write back data cache with
block size of 32 Bytes. The processor sends 32 bit addresses to the cache
controller. Each cache tag directory entry contains, in addition to address tag,
2 valid bits, 1 modified bit and 1 replacement bit. The size of the cache tag
directory is
(a) 160 Kbits (b) 136 bits (c) 40 Kbits (d) 32
bits
[Marks: 2][GATE: 2012]
Q7. In a k-way set associative cache, the cache is divided into v sets, each of which
consists of k lines. The lines of a set are placed in sequence one after another.
The lines in set s are sequenced before the lines in set (s+1). The main memory
blocks are numbered 0 onwards. The main memory block numbered j must
be mapped to any one of the cache lines from.
(a) (j mod v) * k to (j mod v) * k + (k-1)
(b) (j mod v) to (j mod v) + (k-1)
(c) (j mod k) to (j mod k) + (v-1)
(d) (j mod k) * v to (j mod k) * v + (v-1)
[Marks: 1 ][GATE: 2013]
Q8. An access sequence of cache block addresses is of length N and contains n
unique block addresses. The number of unique block addresses between two
consecutive accesses to the same block address is bounded above by k. What
is the miss ratio if the access sequence is passed through a cache of
associativity A ≥ k exercising least-recently-used replacement policy?
(a)n/N (b)1/N (c)1/A (d)k/n
[Marks: 2 ][GATE: 2014] [ SET-1]
Q9. A 4-way set-associative cache memory unit with a capacity of 16 KB is built
using a block size of 8 words. The word length is 32 bits. The size of the
physical address space is 4 GB. The number of bits for the TAG field is _____
[Marks: 1][GATE: 2014] [SET-2]
Q10. 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
[Marks: 2 ][GATE: 2014] [ SET-
2
Q11. If the associativity of a processor cache is doubled while keeping the capacity
and block size unchanged, which one of the following is guaranteed to be NOT
affected?
(a) Width of tag comparator
(b) Width of set index decoder
(c) Width of way selection multiplexor
(d) Width of processor to main memory data bus
[Marks: 2][GATE: 2014] [SET-2]
Q12. The memory access time is 1 nanosecond for a read operation with a hit in
cache, 5 Nanoseconds for a read operation with a miss in cache, 2
nanoseconds for a write operation with a hit in cache and 10 nanoseconds for
a write operation with a miss in cache. Execution of a sequence of instructions
involves 100 instruction fetch operations, 60 memory operand Read
operations and 40 memory operand write operations. The cache hit-ratio is
0.9. The Average memory access time (in nanoseconds) in executing the
sequence of instructions is __________ [Marks: 2 ][GATE: 2014] [ SET-3]
Q13. Assume that for a certain processor, a read request takes 50 nanoseconds on
a cache miss and 5 nanoseconds on a cache hit. Suppose while running a
program, it was observed that 80% of the processors read requests result in a
cache hit. The average and access time in nanoseconds is _______.
[Marks: 1 ][GATE: 2015] [ SET-2]
Q14. Consider a machine with a byte addressable main memory of 220 bytes, block
size of 16 bytes and a direct mapped cache having 212 cache lines. Let the
addresses of two consecutive bytes in main memory be (E201F)16 and
(E2020)16. What are the tag and cache line address (in hex) for main memory
address (E201F)16?
(a) E, 201 (b) F, 201 (c) E, E20 (d) 2, 01F
[Marks: 1 ][GATE: 2015] [ SET-3]
Q15. A processor can support a maximum memory of 4 GB, where the memory is
word-Addressable (a word consists of two bytes). The size of the address bus
of the processor is at ____ least bits [Marks: 1][GATE: 2016]
[SET-1]
Q16. The width of the physical address on a machine is 40 bits. The width of the
tag field in a 512 KB 8-way set associative cache is ____________ bits
[Marks: 2][GATE: 2016] [SET-2]
Q17. A file system uses an in-memory cache to cache disk blocks. The miss rate of
the cache is shown in the figure. The latency to read a block from the cache
is 1 ms and to read a block from the disk is 10 ms. Assume that the cost of
checking whether a block exists in the cache is negligible. Available cache
sizes are in multiples of 10 MB.
The smallest cache size required to ensure an average read latency of less
than 6 ms is _______ [Marks: 2 ][GATE: 2016] [ SET-2]
Q18. Consider a two-level cache hierarchy with L1 and L2 caches. An application
incurs 1.4 memory accesses per instruction on average. For this application,
the miss rate of L1 cache is 0.1; the L2 cache experiences, on average, 7
misses per 1000 instructions. The miss rate L2 expressed correct to two
decimal places is _________. [Marks: 1][GATE: 2017][SET-1]
Q19. Consider a 2-way set associative cache with 256 blocks and uses LRU
replacement, Initially the cache is empty. Conflict misses are those misses
which occur due to contention of multiple Blocks for the same cache set.
Compulsory misses occur due to first time access to the block. The following
sequence of accessed to memory blocks (0, 128, 256, 128, 0, 128, 256, 128,
1, 129, 257,129, 1, 129, 257, 129) is repeated 10 times. The number of conflict
misses experienced by the cache is __________[Marks: 2][GATE: 2017][ SET-
1]
Q20. A cache memory unit with capacity of N words and block size of B words is to
be designed. If it is designed as a direct mapped cache, the length of the TAG
field is 10 bits. If the cache unit is now designed as a 16-way set-associative
cache, the length of the TAG field is ______ bits.
What is the approximate speed up of the pipeline in steady state under ideal
conditions when Compared to the corresponding non-pipeline
implementation?
(a) 4.0 (b) 2.5 (c) 1.1 (d) 3.0
[Marks: 2][GATE: 2011]
Q4. Register renaming is done in pipelined processors
(a) As an alternative to register allocation at compile time
(b) For efficient access to function parameters and local variables
(c) To handle certain kinds of hazards
(d) As part of address translation
[Marks: 2][GATE: 2012]
Q5. 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 I1, I2, I3, …, I12 is 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 (in ns) needed to complete the program is
(a) 132
(b) 165
(c) 176
(d) 328
[Marks: 2][GATE: 2013]
Q6. Consider a 6-stage instruction pipeline, where all stages are perfectly
balanced. Assume that there is no cycle-time overhead of pipelining. When an
application is executing on this 6-stage pipeline, the speedup achieved with
respect to non-pipelined execution if 25% of the instructions incur 2 pipeline
stall cycles is ___________.
[Marks: 2][GATE: 2014] [SET-1]
Q7. Consider two processors P1 and P2 executing the same instruction set. Assume
that under identical conditions, for the same input, a program running on P2
takes 25% less time but incurs 20% more CPI (clock cycles per instruction) as
compared to the program running on P1. If the clock frequency of P1 is 1GHz,
then the clock frequency of P2 (in GHz) is _____
[Marks: 2][GATE: 2014] [SET-1]
Q8. Consider the following processors (ns stands for nanoseconds). Assume that
the pipeline registers have zero latency
P1: Four-stage pipeline with stage latencies 1 ns, 2 ns, 2 ns, 1 ns.
P2: Four-stage pipeline with stage latencies 1 ns, 1.5 ns, 1.5 ns, 1.5 ns.
P3: Five-stage pipeline with stage latencies 0.5 ns, 1 ns, 1 ns, 0.6 ns, 1 ns.
P4: Five-stage pipeline with stage latencies 0.5 ns, 0.5 ns, 1 ns, 1 ns, 1.1 ns.
Which processor has the highest peak clock frequency?
(a) P1
(b) P2
(c) P3
(d) P4
S2 and 𝑆3.
The minimum average latency (MAL) is ______[Marks: 2][GATE: 2015] [SET-3]
Q13. Consider the following code sequence having five instructions 𝐼1 to 𝐼5. Each of
these instructions has the following format.
OP Ri, Rj, Rk
Where operation OP is performed on contents of registers Rj and Rk and the
result is stored in register Ri.
𝐼1: ADD R1, R2, R3
𝐼2: MUL R7, R1, R3
𝐼3: SUB R4, R1, R5
𝐼4: ADD R3, R2, R4
𝐼5: MUL R7, R8, R9
Consider the following three statements.
S1: There is an anti-dependence between instructions 𝐼2 and 𝐼5
S2: There is an anti-dependence between instructions 𝐼2 and 𝐼4
S3: Within an instruction pipeline anti-dependence always creates one or
more stalls which one of above statements is/are correct?
(a) Only S1 is true (b) Only S2 is true
(c) Only S1 and S3 are true (d) Only S2 and S3 are true
[Marks: 1][GATE: 2015][SET-3]
Q14. The stage delays in a 4-stage pipeline are 800, 500, 400 and 300 picoseconds.
The first stage (with delay 800 picoseconds) is replaced with functionally
equivalent design involving two stages with respective delays 600 and 350
picoseconds. The throughput increase of the pipeline is _____________________
[Marks: 2][GATE: 2016] [SET-1]
Q15. Consider a 3 GHz (gigahertz) processor with a three-stage pipeline and stage
latencies τ1, τ2, τ3 and such that τ1 = 3τ2/4 = 2τ3. If the longest pipeline stage
is split into two pipeline stages of equal latency, the new frequency is _________
GHz, ignoring delays in the pipeline registers.
[Marks: 2][GATE: 2016] [SET-2]
Q16. Suppose the functions F and G can be computed in 5 and 3 nanoseconds by
functional units UF and UG, respectively. Given two instances of UF and two
instances of UG, it is required to implement the computation F (G(Xi)) for 1 ≤ i
≤ 10. Ignoring all other delays, the minimum time required to complete this
computation is _________ nanoseconds.[Marks: 2][GATE: 2016][SET-2]
Q17. Instruction execution in a processor is divided into 5 stage, Instruction Fetch
(IF), Instruction decode (ID), Operand Fetch (OF), Execute (EX), and Write Back
(WB). These stages take 5, 4, 20, 10, and 3 nanoseconds (ns) respectively. A
pipelined implementation of the processor requires buffering between each
pair of consecutive stages with a delay of 2 ns. Two pipelined implementations
of the processor are contemplated;
a naive pipeline implementation (NP) with 5 stages and
An efficient pipeline (EP) where the OF stage is divided into stages OF1 and
OF2 with Execution times of 12 ns respectively.
The speedup (correct to two decimal places) achived by EP over NP in executing
20 Independent instructions with no hazards is __________.
[Marks: 2][GATE: 2017][ SET-1]
Q18. Consider a RISC machine where each instruction is exactly 4 bytes long.
Conditional and unconditional branch instructions use PC - relative
addressing mode with Offset specified in bytes to the target location of the
branch instruction. Further the Offset is always with respect to the address of
the next instruction in the program sequence. Consider the following
instruction sequence. If the target of the branch instruction is i, then the
decimal value of the Offset is __________.
Instr. No. Instruction
i: add R2, R3, R4
i+1: sub R5, R6, R7
i+2: cmp R1, R9, R10
i+3: beq R1, Offset
[Marks: 2][GATE: 2017][SET-1]
Q19. The instruction pipeline of a RISC processor has the following stages:
Instruction Fetch (IF), Instruction Decode (ID), Operand Fetch (OF), Perform
Operation (PO) and Writeback (WB). The IF, ID, OF and WB stages take 1 clock
cycle each for every instruction. Consider a Sequence of 100 instructions. In
the PO stage, 40 instructions take 3 clock cycles each, 35 instructions take 2
clock cycles each, and the remaining 25 instructions take 1 clock cycle each.
Assume that there are no data hazards and no control hazards. The number
of clock cycles required for completion of execution of the sequence of
instructions is ______.
[Marks: 2][GATE: 2018]
Q20. Consider a non-pipelined processor operating at 2.5 GHz. It takes 5 clock
cycles to complete an instruction. You are going to make a 5-stage pipeline out
of this processor. Overheads associated with pipelining force you to operate
the pipelined processor at 2 GHz. In a given program, assume that 30% are
memory instructions, 60% are ALU instructions and the rest are branch
instructions. 5% of the memory instructions cause stalls of 50 clock cycles
each due to cache misses and 50% of the branch instructions cause stalls of
2 cycles each. Assume that there are no stalls associated with the execution of
ALU instructions. For this program, the speedup achieved by the pipelined
processor over the non-pipelined processor (round off to 2 decimal places) is
_____. [Marks: 2][GATE: 2020]
Input – Output and Control
Q1. A computer handles several interrupt sources of which the following are
relevant for this question.
Interrupt from CPU temperature sensor (raises interrupt if CPU
temperature is too high)
Interrupt from Mouse(raises interrupt if the mouse is moved or a button is
pressed)
Interrupt from Keyboard(raises interrupt when a key is pressed or
released)
Interrupt from Hard Disk(raises interrupt when a disk read is completed)
Which one of these will be handled at the HIGHEST priority?
(a) Interrupt from Hard Disk
(b) Interrupt from Mouse
(c) Interrupt from Keyboard
(d) Interrupt from CPU temperature sensor [Marks: 1][GATE:
2011]
Q2. A hard disk has 63 sectors per track, 10 platters each with 2 recording
surfaces and 1000 cylinders. The address of a sector is given as a triple (c, h,
s), where c is the cylinder number, h is the surface number and s is the sector
number. Thus, the 0th sector is addressed as (0, 0, 0), the 1st sector as (0, 0,
1), and so on. The address <400, 16, 29> corresponds to sector number:
(a) 505035
(b) 505036
(c) 505037
(d) 505038
[Marks: 2][GATE: 2009
Q3. A hard disk has 63 sectors per track, 10 platters each with 2 recording
surfaces and 1000 cylinders. The address of a sector is given as a triple (c, h,
s), where c is the cylinder number, h is the surface number and s is the
sector number. Thus, the 0th sector is addressed as (0, 0, 0), the 1st sector
as (0, 0, 1), and so on. The address 1039th corresponds to sector number:
(a) (0,15,31)
(b) (0,16,30)
(c) (0,16,31)
(d) (0,17,31) [Marks: 2][GATE: 2009]
Q4. A CPU generally handles an interrupt by executing an interrupt service
routine
(a) As soon as an interrupt is raised.
(b) By checking the interrupt register at the end of fetch cycle.
(c) By checking the interrupt register after finishing the execution of the
current instruction.
(d) By checking the interrupt register at fixed time intervals
[Marks: 2][GATE: 2009]
Q5. A main memory unit with a capacity of 4 megabytes is built using 1M × 1-bit
DRAM chips. Each DRAM chip has 1K rows of cells with 1K cells in each row.
The time taken for a single refresh operation is 100 nanoseconds. The time
required to perform one refresh operation on all the cells in the memory unit
is
(a) 100 nanoseconds
(b) 100×210 nanoseconds
(c) 100×220 nanoseconds
(d) 3200×220 nanoseconds [Marks: 1][GATE: 2010]
Q6. On a non-pipelined sequential processor, a program segment, which is a part
of the interrupt service routine, is given to transfer 500 bytes from an I/O
device to memory.
Initialize the address register
Initialize the count to 500
LOOP: Load a byte from device
Store in memory at address given by address register
Increment the address register
Decrement the count
If count != 0 go to LOOP
Assume that each statement in this program is equivalent to machine
instruction which takes one clock cycle to execute if it is a non-load/store
instruction. The load-store instructions take two clock cycles to execute. The
designer of the system also has an alternate approach of using DMA controller
to implement the same transfer. The DMA controller requires 20 clock cycles
for initialization and other overheads. Each DMA transfer cycle takes two clock
cycles to transfer one byte of data from the device to the memory. What is the
approximate speedup when the DMA controller based design is used in place
of the interrupt driven program based input-output?
(a) 3.4 (b) 4.4 (c) 5.1 (d) 6.7
[Marks: 2][GATE: 2011]
Q7. An application loads 100 libraries at start-up. Loading each library requires
exactly one disk access. The seek time of the disk to a random location is given
as 10 ms. Rotational speed of disk is 6000 rpm. If all 100 libraries are loaded
from random locations on the disk, how long does it take to load all libraries?
(The time to transfer data from the disk block once the head has been
positioned at the start of the block may be neglected)
(a) 0.50 sec (b) 1.50 sec (c) 1.25 sec (d) 1.00 sec
[Marks: 1][GATE: 2011]
Q12. Consider a main memory system that consists of 8 memory modules attached
to the system bus, Which is one word wide. When a write request is made, the
bus is occupied for 100 nanoseconds (ns) By the data, address, and control
signals. During the same 100 ns, and for 500 ns thereafter, the addressed
memory module executes one cycle accepting and storing the data. The
(internal) Operation of different memory modules may overlap in time, but only
one request can be on the bus at any time. The maximum number of stores (of
one word each) that can be initiated in 1 Millisecond is ____________
[Marks: 2][GATE: 2014][SET-2]
Q13. Consider a disk pack with a seek time of 4 milliseconds and rotational speed
of 10000 rotations per minute (RPM). It has 600 sectors per track and each
sector can store 512 bytes of data. Consider a file stored in the disk. The file
contains 2000 sectors. Assume that every sector access Necessitates a seek,
and the average rotational latency for accessing each sector is half of the time
For one complete rotation. The total time (in milliseconds) needed to read the
entire file is ____________. [Marks: 2][GATE: 2015] [SET-1]
Q14. Consider a typical disk that rotates at 15000 rotations per minute (RPM) and
has a transfer rate of 50×106 bytes/sec. If the average seek time of the disk is
twice the average rotational delay and the controller’s transfer time is 10 times
the disk transfer time, the average time (in milliseconds) to read or write a 512-
byte sector of the disk is ____________. [Marks: 2][GATE: 2015][SET-
2]
Q15. Consider a processor with byte-addressable memory. Assume that all
registers, including Program Counter (PC) and Program Status Word (PSW),
are of size 2 bytes. A stack in the main memory is implemented from memory
location (0100)16 and it grows upward. The stack pointer (SP) points to the top
element of the stack. The current value of SP is (016E)16. The CALL instruction
is of two words, the first word is the op-code and the second word is the
starting address of the subroutine (one word = 2 bytes). The CALL instruction
is implemented as follows:
• Store the current value of PC in the stack
• Store the value of PSW register in the stack
• Load the starting address of the subroutine in PC
The content of PC just before the fetch of a CALL instruction is (5FA0)16. After
execution of the CALL instruction, the value of the stack pointer is
(a) (016A)16 (b) (016C)16
(c) (0170)16 (d) (0172)16
Q16. The size of the data count register of a DMA controller is 16 bits. The processor
needs to transfer a file of 29,154 kilobytes from disk to main memory. The
memory is byte addressable. The minimum number of times the DMA
controller needs to get the control of the system bus from the processor to
transfer the file from the disk to main memory is _________.
[Marks: 2][GATE: 2016] [SET-1]
Q17. The following are some events that occur after a device controller issues an
interrupt while Process L is under execution.
(P) The processor pushes the process status of L onto the control stack.
(Q) The processor finishes the execution of the current instruction.
(R) The processor executes the interrupt service routine.
(S) The processor pops the process status of L from the control stack.
(T) The processor loads the new PC value based on the interrupt.
Which one of the following is the correct order in which the events above
occur?
(a) QPTRS
(b) PTRSQ
(c) TRPQS
(d) QTPRS
[Marks: 1][GATE: 2018]
Q18. A 32-bit wide main memory unit with a capacity of 1 GB is built using 256M
× 4-bit DRAM Chips. The number of rows of memory cells in the DRAM chip is
214. The time taken to perform one refresh operation is 50 nanoseconds. The
refresh period is 2 milliseconds. The Percentage (rounded to the closest integer)
of the time available for performing the memory Read/write operations in the
main memory unit is __________.
Q19. The chip select logic for a certain DRAM chip in a memory system design is
shown below. Assume that the memory system has 16 address lines denoted
by A15 to A0. What is the range of addresses (in hexadecimal) of the memory
system that can get enabled by the chip select (CS) signal?
1. D 2. C 3. C 4. D 5. C
6. A 7. A 8. A 9. 20 10. D
11. D 12. 1.68 13. 14 14. A 15. 31
16. 24 17. 30 18. 0.05 19. 76 20. 14
21. A 22. 4.72 23. 18 24. B 25. D
26. 160 27. 13.5 28. D
1. D 2. 16383 3. A 4. 16 5. 500
6. D 7. D 8. 32 9. 14
Instruction Pipeline
1. D 2. B 3. B 4. C 5. B
6. 4 7. 1.6 8. C 9. 1.54 10. 3.2
11. 13 12. 3 13. B 14. 33 15. 4
16. 28 17. 1.50 18. - 16 19. 219 20. 2.16
1. D 2. C 3. C 4. C 5. B
6. A 7. B 8. D 9. D 10. D
11. B 12. 10000 13. 14020 14. 6.1 15. D
16. 456 17. A 18. 59 to 60 19. B 20. D
21. C
GATE Computer Science & IT
Database
Management System
(Topic-wise)
(https://www.youtube.com/playlist?list=PLqHw2_FIWUza5ijANRnWWpy68PPET4sHK)
Structure Query Language and Relational Algebra
Q1. Let R and S be relational schemes such that R = {a, b, c} and S = {c}. Now
consider the following queries on the database
I. πR−S(r) − πR−S (πR−S(r) × s − πR−S,S(r))
II. {t ∈πR−S(r) ∧∀u∈s (∃v∈r(u = v[S] ∧t = v[R−S]))}
III. {t ∈πR−S(r) ∧∀v∈r (∃u∈s (u = v[S] ∧t = v[R−S]))}
IV. Select R.a, R.b From R, S Where R.c = S.c
Which of the above queries are equivalent?
(a) I and II
(b) I and III
(c) II and IV
(d) III and IV
[Marks: 2][GATE: 2009]
Q2. Consider the following relational schema:
Suppliers(sid:integer, sname:string, city:string, street:string)
Parts(pid:integer, pname:string, color:string)
Catalog(sid:integer, pid:integer, cost:real)
Consider the following relational query on the above database:
SELECT S.sname
FROM Suppliers S
WHERE S.sid NOT IN (SELECT C.sid
FROM Catalog C
WHERE C.pid NOT IN (SELECT P.pid
FROM Parts P
WHERE P.color<> 'blue'))
Assume that relations corresponding to the above schema are not empty.
Which one of the following is the correct interpretation of the above query?
(a) Find the names of all suppliers who have supplied a non-blue part.
(b) Find the names of all suppliers who have not supplied a non-blue part.
(c) Find the names of all suppliers who have supplied only blue parts.
(d) Find the names of all suppliers who have not supplied only blue parts.
[Marks: 2][GATE: 2009]
Q3. A relational schema for a train reservation database is given below.
Passenger (pid, pname, age)
Reservation (pid, class, tid)
Table: Passenger Table : Reservation
Pid Pname Age Pid Classs Tid
0 Sachin 65 0 AC 8200
1 Rahul 66 1 AC 8201
2 Sourav 67 2 SC 8201
3 Anil 69 5 AC 8203
1 SC 8204
3 AC 8202
What pids are returned by the following SQL query for the above instance of
the tables?
SELECT pid
FROM Reservation
WHERE class = ‘AC’ AND EXISTS (SELECT * FROM Passenger
WHERE age > 65 AND
Passenger.pid = Reservation.pid)
(a) 1,0 (b) 1, 2
(c) 1, 3 (d) 1, 5
[Marks: 1][GATE:2010]
Q4. Consider a database table T containing two columns X and Y each of type
integer. After the creation of the table, one record (X = 1, Y = 1) is inserted in
the table. Let MX and MY denote the respective maximum values of X and Y
among all records in the table at any point in time. Using MX and MY, new
records are inserted in the table 128 times with X and Y values being MX +
1, 2*MY + 1 respectively. It may be noted that each time after the insertion,
values of MX and MY change. What will be the output of the following SQL
query after the steps mentioned above are carried out?
SELECT Y FROM T WHERE X = 7;
(a) 127
(b) 255
(c) 129
(d) 257
[Marks: 2][GATE:2011
Q5. Database table by name Loan_Records is given below.
Borrower Bank_Manager Loan_Amount
Ramesh Sunderajan 10000.00
Suresh Ramgopal 5000.00
Mahesh Sunderajan 7000.00
What is the output of the following SQL query?
SELECT Count(*)
FROM ((SELECT Borrower, Bank_Manager FROM Loan_Records) AS S
NATURAL JOIN
(SELECT Bank_Manager, Loan_Amount FROM Loan_Records) AS T);
(a) 3 (b) 9 (c) 5 (d) 6
[Marks: 2][GATE: 2011]
Q6. Which of the following statements are TRUE about an SQL query?
P: An SQL query can contain a HAVING clause even if it does not have a
GROUP BY clause
Q: An SQL query can contain a HAVING clause only if it has a GROUP BY
clause
R: All attributes used in the GROUP BY clause must appear in the SELECT
clause
S: Not all attributes used in the GROUP BY clause need to appear in the
SELECT clause
(a) P and R (b) P and S (c) Q and R (d) Q and S
[Marks: 1][GATE: 2012]
Q7. Suppose R1(A, B) and R2(C, D) are two relation schemas. Let r1 and r2 be
the corresponding relation instances. B is a foreign key that refers to C in r2.
If data in r1 and r2 satisfy referential integrity constraints, which of the
following is ALWAYS TRUE?
(a) ΠB(r1 C(r2) =∅
(b) ΠC(r2) − ΠB(r1) = ∅
(c) ΠB(r1 C(r2)
How many tuples does the result of the following SQL query contain?
SELECT A.Id
FROM A
WHERE A.Age> ALL(SELECT B.Age
FORM B
WHERE B Name =’Arun’)
(a)4 (b)3 (c)0 (d)1
[Marks: 2][GATE:
2012]
Q10. Consider the following relational schema.
Students (rollno: integer, sname: string)
Courses (course no: integer, cname: string)
Registration (rollno: integer, course no: integer, percent: real)
Which of the following queries are equivalent to this query in English?
"Find the distinct names of all students who score more than 90% in the
course numbered 107"
(i) SELECT DISTINCT S.sname
FROM Students as S, Registration as R
WHERE R.rollno = S.rollno AND R.courseno =107 AND R.percent
> 90
(ii) Πsname(σcourseno = 107 ∧percent > 90(Registration ⋈Students))
(iii) {T ∣∃S ∈Students, ∃R ∈Registration(S.rollno = R.rollno
∧R.courseno = 107 ∧R.percent > 90 ∧T.sname = S.sname)}
(iv) {<SN>∣∃SR ∃RP (<SR,SN>∈Students ∧<SR,107,RP>∈Registration ∧RP > 90)
(a) I, II, III and IV (b) I, II and III only
(c) I, II and IV only (d) II, III and IV only
[Marks: 2][GATE: 2013]
Q11. Given the following statements:
S1: A foreign key declaration can always be replaced by an equivalent check
assertion in SQL.
S2: Given the table R(a, b, c) where a and b together form the primary key,
the following is a valid table definition.
CREATE TABLE S (
a INTEGER,
d INTEGER,
e INTEGER,
PRIMARY KEY (d),
FOREIGN KEY (a) references R
)
Which one of the following statements is CORRECT?
(a) S1 is TRUE and S2 is FALSE.
(b) Both S1 and S2 are TRUE.
(c) S1 is FALSE and S2 is TRUE.
(d) Both S1 and S2 are FALSE. [Marks: 1][GATE: 2014][SET-1]
Q12. Given the following schema:
employees(emp-id, first-name, last-name, hire-date, dept-id, salary)
departments(dept-id, dept-name, manager-id, location-id)
You want to display the last names and hire dates of all latest hires in their
respective departments in the location ID 1700. You issue the following
query:
SELECT last-name, hire-date
FROM employees
WHERE (dept-id, hire-date) IN (SELECT dept-id, MAX(hire-date) FROM
employees JOIN departments USING (dept-id) WHERE location-id = 1700
GROUP BY dept-id);
What is the outcome?
(a) It executes but does not give the correct result.
(b) It executes and gives the correct result.
(c) It generates an error because of pairwise comparison.
(d) It generates an error because the GROUP BY clause cannot be used with
table joins in a subquery.
[Marks: 2][GATE: 2014][SET-1]
Q13. SQL allows tuples in relations, and correspondingly defines the multiplicity
of tuples in the result of joins. Which one of the following queries always gives
the same answer as the nested query shown below:
select * from R where a in (select S.a from S)
(a) select R.* from R, S where R.a = S.a
(b) select distinct R.* from R,S where R.a = S.a
(c) select R.* from R, (select distinct a from S) as S1 where R.a = S1.a
(d) select R.* from R,S where R.a = S.a and is unique R
54 [Marks: 2][GATE: 2014][SET-2]
Q14. What is the optimized version of the relation algebra expression
πA1(πA2(σF1(σF2(r)))), where A1, A2 are sets of attributes in r with A1 ⊂A2 and
F1, F2 are Boolean expressions based on the attributes in r?
(a) πA1(σ(F1∧F2)(r)) (b) πA1(σ(F1∨F2)(r))
(c) πA2(σ(F1∧F2)(r)) (d) πA2(σ(F1∨F2)(r))
21 [Marks: 2][GATE: 2014][SET-3]
Q15. Consider the relational schema given below, where eId of the relation
dependent is a foreign key referring to empId of the relation employee.
Assume that every employee has at least one associated dependent in the
dependent relation.
Employee (empId, empName, empAge)
Dependent(depId, eId, depName, depAge)
Consider the following relational algebra query:
ΠempId(employee)−ΠempId(employee ⋈ (empId=eID)∧(empAge≤depAge)depen
dent)
The above query evaluates to the set of empIds of employees whose age is
greater than that of
(a) Some dependent.
(b) All dependents.
(c) Some of his/her dependents.
(d) All of his/her dependents.
[Marks: 2][GATE: 2014][SET-3]
Q16. Consider the following relational schema:
employee(empId, empName, empDept)
customer(custId, custName, salesRepId, rating)
SalesRepId is a foreign key referring to empId of the employee relation.
Assume that each employee makes a sale to at least one customer. What
does the following query return?
SELECT empName
FROM employee E
WHERE NOT EXISTS (SELECT custId
FROM customer C
WHERE C.salesRepId = E.empId AND C.rating <>
'GOOD');
(a) Names of all the employees with at least one of their customers having a
‘GOOD’ rating.
(b) Names of all the employees with at most one of their customers having a
‘GOOD’ rating.
(c) Names of all the employees with none of their customers having a
‘GOOD’ rating.
(d) Names of all the employees with all their customers having a ‘GOOD’
rating.
[Marks: 2][GATE: 2014][SET-3]
Q17. SELECT operation in SQL is equivalent to
(a) the selection operation in relational algebra
(b) the selection operation in relational algebra, except that SELECT in SQL
retains duplicates
(c) the projection operation in relational algebra
(d) the projection operation in relational algebra, except that SELECT in
SQL retains duplicates
[Marks: 1][GATE: 2015][SET-1]
Q18. Consider the following relations:
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
_________.
[Marks:1][GATE: 2017][SET-2]
Q25. Consider the following database table named top_scorer.
Q27. Consider the following two tables and four queries in SQL.
Book (isbn, bname), Stock (isbn, copies)
Query 1: SELECT B.isbn, S.copies
FROM Book B INNER JOIN Stock S
ON B.isbn = S.isbn;
Query 2: SELECT B.isbn, S.copies
FROM Book B LEFT OUTER JOIN Stock S
ON B.isbn = S.isbn;
Query 3: SELECT B.isbn, S.copies
FROM Book B RIGHT OUTER JOIN Stock S
ON B.isbn = S.isbn;
Query 4: SELECT B.isbn, S.copies
FROM Book B FULL OUTER JOIN Stock S
ON B.isbn = S.isbn;
Which one of the queries above is certain to have an output that is a superset
of the outputs of the other three queries?
(a) Query 1
(b) Query 2
(c) Query 3
(d) Query 4
[Marks: 1][GATE: 2018]
Q28. A relational database contains two tables Student and Performance as shown
below:
The primary key of the Student table is Roll_no. For the Performance table,
the columns Roll_no. and Subject_code together from the primary key.
Consider the SQL query given below:
SELECT S.Student_name, sum(P.Marks)
FROM Student S, Performance P
WHERE P.Marks > 84
GROUP BY S.Student_name;
The number of rows returned by the above SQL query is _________.
[Marks: 2][GATE: 2019]
Q29. Consider the following relation P(X, Y, Z), Q(X, Y, T) and R(Y, V):
How many tuples will be returned by the following relational algebra query?
Пx(σP.Y=R.Y ∧ R.V=V2(P × R)) - Пx(σQ.Y=R.Y ∧ Q.T>2(Q × R))
[Marks: 2][GATE: 2019]
Q30. Consider a relational database containing the following schemas.
For (StudentName, StudentAge) to be the key for this instance, the value X
should not be equal to ____________
[Marks: 2][GATE: 2014][SET-2]
Q11. A prime attribute of a relation scheme R is an attribute that appears
(A) in all candidate keys of R.
(B) in some candidate key of R.
(C) in a foreign key of R.
(D) only in the primary key of R.
[Marks: 2][GATE: 2014][SET-3]
Q12. Consider the relation X(P, Q, R, S, T, U) with the following set of functional
dependencies
𝐹={
{𝑃,𝑅}→{𝑆,𝑇},
{𝑃,𝑆,𝑈}→{𝑄,𝑅}
}
Which of the following is the trivial functional dependency in 𝐹+, where 𝐹+ is
closure of F?
(a) {𝑃,𝑅} → {𝑆,𝑇} (b) {𝑃,𝑅} → {𝑅,𝑇}
(c) {𝑃,𝑆} → {𝑆} (d) {𝑃, 𝑆, 𝑈} → {𝑄}
[Marks:1][GATE: 2015][SET-3]
Q13. Which of the following is NOT a super key in a relational schema with
attributes V, W, X, Y, Z and primary key VY?
(a) VXYZ
(b) VWXZ
(c) VWXY
(d) VWXYZ [Marks: 1][GATE: 2016][SET-1]
Q14. A database of research articles in a journal uses the following schema.
(VOLUME, NUMBER, STARTPAGE, ENDPAGE, TITLE, YEAR, PRICE)
The primary key is (VOLUME, NUMBER, STARTPAGE, ENDPAGE) and the
following
Functional dependencies exist in the schema.
(VOLUME, NUMBER, STARTPAGE, ENDPAGE) → TITLE
(VOLUME, NUMBER) → YEAR
(VOLUME, NUMBER, STARTPAGE, ENDPAGE) → PRICE
The database is redesigned to use the following schemas.
(VOLUME, NUMBER, STARTPAGE, ENDPAGE, TITLE, PRICE)
(VOLUME, NUMBER, YEAR)
Which is the weakest normal form that the new database satisfies, but the
old one does not?
(a) 1NF
(b) 2NF
(c) 3NF
(d) BCNF [Marks: 1][GATE: 2016][SET-1]
Q15. The following functional dependencies hold true for the relational schema {V,
W, X, Y, Z} :
V→W
VW → X
Y → VX
Y→Z
Which of the following is irreducible equivalent for this set of functional
dependencies?
(a) (b)
V→W V→W
V→X W→X
Y→V Y→V
Y→Z Y→Z
(c) (d)
V→W V→W
V→X W→X
Y→V Y→V
Y→X Y→X
Y→Z Y→Z
[Marks: 1][GATE: 2017][SET-1]
Q16. Consider the following four relational schemas. For each schema, all non-
trivial functional dependencies are listed. The underlined attributes are the
respective primary keys.
Query I: Registration(rollno, courses)
Field ‘courses’ is a set-valued attribute containing the set of courses a student
has registered for. Non-trivial functional dependency
rollno → courses
Query II: Registration (rollno, coursid, email)
Non-trivial functional dependencies:
rollno, courseid → email
email → rollno
Query III: Registration (rollno, courseid, marks, grade)
Non-trivial functional dependencies:
rollno, courseid, → marks, grade
marks → grade
Query IV: Registration (rollno, courseid, credit)
Non-trivial functional dependencies:
rollno, courseid → credit
courseid → credit
Which one of the relational schemas above is in 3NF but not in BCNF?
(a) Query 1 (b) Query 2 (c) Query 3 (d) Query 4
[Marks: 2][GATE: 2018]
Which one of the following choices gives a possible order in which the key
values could have been inserted in the table?
(a) 46, 42, 34, 52, 23, 33
(b) 34, 42, 23, 52, 33, 46
(c) 46, 34, 42, 23, 52, 33
(d) 42, 46, 33, 23, 34, 52
[Marks: 2][GATE: 2010]
Q5. A hash table of length 10 uses open addressing with hash function h(k) = k
mod 10, and linear probing. After inserting 6 values into an empty hash table,
the table is as shown below.
How many different insertion sequences of the key values using the same
hash function and linear probing will result in the hash table shown above?
(a) 10
(b) 20
(c) 30
(d) 40 [Marks: 2][GATE:
2010]
Q9. Consider a join (relation algebra) between relations r(R) and s(S) using the
nested loop method. There are 3 buffers each of size equal to disk block size,
out of which one buffer is reserved for intermediate results. Assuming
size(r(R))<size(s(S)), the join will have fewer number of disk block accesses if
(a) Relation r(R) is in the outer loop.
(b) Relation s(S) is in the outer loop.
(c) Join selection factor between r(R) and s(S) is more than 0.5.
(d) Join selection factor between r(R) and s(S) is less than 0.5.
[Marks: 2][GATE: 2014][SET-2]
Q10. A file is organized so that the ordering of data records is the same as or close
to the ordering of data entries in some index. Then that index is called
(a) Dense (b) Sparse (c) Clustered (d)
Unclustered
[Marks: 1][GATE: 2015][SET-1]
Q11. With reference to the B+-tree index of order 1 shown below, the minimum
number of nodes (including the Root node) that must be fetched in order to
satisfy the following query: "Get all records with a search key greater than or
equal to 7 and less than 15" is ____________.
[Marks:1][GATE: 2015][SET-2]
Q12. Which one of the following hash functions on integers will distribute keys
most uniformly over 10 buckets numbered 0 to 9 for 𝑖 ranging from 0 to
2020?
(a) ℎ(𝑖) = 𝑖2 mod 10
(b) ℎ(𝑖) = 𝑖3 mod 10
(c) ℎ(𝑖) = (11 ∗𝑖2) mod 10
(d) ℎ(𝑖) = (12 ∗𝑖) mod 10
[Marks: 2][GATE: 2015][SET-2]
Q13. Given a hash table 𝑇 with 25 slots that stores 2000 elements, the load factor
𝛼 for 𝑇 is ________.
[Marks: 1][GATE: 2015][SET-3]
Q14. Consider a B+ tree in which the search key is 12 bytes long, block size is 1024
bytes, record pointer is 10 bytes long and block pointer is 8 bytes long. The
maximum number of keys that can be accommodated in each non-leaf node
of the tree is ____________.
[Marks: 1][GATE: 2015][SET-3]
Which one of the schedules below is the correct serialization of the above?
(a) T1T3T2 (b) T2T1T3
(c) T2T3T1 (d) T3T1T2
[Marks: 2][GATE: 2010]
Q4. Consider the following transactions with data items P and Q initialized to zero:
T1: read(P); T2: read(Q);
read(Q); read(P);
if P = 0 then Q: = Q + 1; if Q = 0 then P: = P + 1;
write (Q); write (P);
Any non-serial interleaving of T1 and T2 for concurrent execution leads to
(a) A serializable schedule
(b) A schedule that is not conflict serializable
(c) A conflict serializable schedule
(d) A schedule for which a precedence graph cannot be drawn
[Marks: 2][GATE: 2012]
Q5. Consider the following four schedules due to three transactions (indicated by
the subscript) using read and write on a data item x, denoted by r(x) and w(x)
respectively. Which one of them is conflict serializable?
(a) r1(x); r2(x); w1(x); r3(x); w2(x)
(b) r2(x); r1(x); w2(x); r3(x); w1(x)
(c) r3(x); r2(x); r1(x); w2(x); w1(x)
(d) r2(x); w2(x); r3(x); r1(x); w1(x) [Marks: 2][GATE: 2014][SET-1]
Q6. Consider the following schedule S of transactions T1, T2, T3, T4:
S1: r1(X); r3(Y); r3(X); r2(Y); r2(Z); w3(Y); w2(Z); r1(Z); w1(X); w1(Z)
S2: r1(X); r3(Y); r2(Y); r3(X); r1(Z); r2(Z); w3(Y); w1(X); w2(Z); w1(Z)
Here, RX stands for “Read(X)” and WX stands for “Write(X)”. Which one of the
following schedules is conflict equivalent to the above schedule?
(a)
(b)
(c)
(d)
1. C 2. C 3. B 4. C 5. C
6. C 7. C 8. A 9. A 10. C
11. 5 12. B 13. A 14. 50 15. A
16. 52 17. B 18. 4
Transaction
1. B 2. B 3. A 4. B 5. D
6. C 7. A 8. B 9. A 10. B
11. B 12. A 13. A 14. C 15. A
16. 54 17. C 18. A
ER
1. C 2. 4 3. C 4. A 5. C
GATE PAPERS
Digital
PYQ Questions Booklet
Video Solution Play list Link of Operating System: Click Here
(https://www.youtube.com/playlist?list=PLqHw2_FIWUzafAytnFoEA_MqIdpQfSXKa)
(1217)8 is equivalent to
Q1.
(a)(1217)16 (b) (028F)16 (c)(2297)10 (d)(0B17)16
[Marks:][GATE: 2009
What is the minimum number of gates required to implement the Boolean function (AB+C
Q2.
have to use only 2-input NOR gates?
(a)2 (b)3 (c)4 (d)5
[Marks: ][GATE:
The minterm expansion of f(P, Q, R) = PQ + QR’ + PR’ is
Q3.
(a) m2 + m4 + m6 + m7 (b) m0 + m1 + m3 + m5
(c) m0 + m1 + m6 + m7 (d) m2 + m3 + m4 + m5
[Marks: 1][GATE:
P is a 16-bit signed integer. The 2's complement representation of P is (F87B)16. T
Q4.
complement representation of 8*P is
(a) (C3D8)16
(b) (187B)16
(c)(F878)16
(d)(987B)16
[Marks: 1][GATE:
The Boolean expression for the output ‘f’ of the multiplexer shown below is
Q5.
(a) (PQR)’
(b) PQR
(c) (P+Q+R)’
(d) P+Q+R
[Marks: 1 ][GATE: 2010]
What is the Boolean expression for the output f of the combinational logic circuit of NOR
Q6.
given below?
[Marks: 1][GATE:
Consider the following circuit involving three D-type flip-flops used in a certain type of c
Q11.
configuration.
If all the flip-flops were reset to 0 at power on, what is the total number of distinct outputs (
represented by PQR generated by the counter?
(a) 3 (b) 4 (c) 5 (d) 6
[Marks: 2 ][GATE:
Consider the following circuit involving three D-type flip-flops used in a certain type of c
Q12.
configuration If at some instance prior to the occurrence of the clock edge, P, Q and R
value 0, 1 and 0 respectively, what shall be the value of PQR after the clock edge?
(a) b’d’
(b) b’d’ + b’c’
(c) b’d’ + a’b’c’d’
(d) b’d’ + b’c’ + c’d’
[Marks: 2 ][GATE:
Which one of the following expressions does NOT represent exclusive NOR of x and y?
Q16.
(a) xy+x’y’
(b) x⊕y’
(c) x’⊕y
(d) x’⊕y’
[Marks: 1 ][GATE:
The smallest integer that can be represented by an 8-bit number in 2’s complement form i
Q17.
(a) -256
(b)-128
(c)-127
(d)0
[Marks: 1][GATE:
Q18. In the following truth table, V = 1 if and only if the input is valid.
What function does the truth table represent?
(a) Priority encoder (b) Decoder (c) Multiplexer (d) Demultiplexer
[Marks: 1 ][GATE: 2013]
Q19. Consider the following Boolean expression for F:
F(P, Q, R, S) = PQ + P'QR + P'QR'S
The minimal sum-of-products form of F is
(a) PQ + QR + QS (b) P + Q + R + S
(c) P’ + Q’ + R’ + S’ (d) P’R + P’R’S + P
[Marks: 1 ][GATE: 2014][ SET-1]
Q20. The base (or radix) of the number system such that the following equation holds
is____________.312/20 = 13.1
[Marks: 1 ][GATE: 2014] [ SET-1]
Q21. Consider a 4-to-1 multiplexer with two select lines S1 and S0, given below
The minimal sum-of-products form of the Boolean expression for the output F
of the multiplexer is
(a) P’Q + QR’ + PQ’R (b) P’Q + P’QR’ + PQR’ + PQ’R
(c) P’QR + P’QR’ + QR’ + PQ’R (d) PQR’
[Marks: 2 ][GATE: 2014] [ SET-1]
Q22. The dual of a Boolean function f(x1, x2… xn, +, ∙, ′), written as FD, is the same
expression as that of F with + and. Swapped. F is said to be self-dual if F = FD. The
number of self-dual functions with n Boolean variables is
𝑛 n−1
(a) 2n (b) 2n-1 (c) 22 (d)22
[Marks: 1 ][GATE: 2014] [ SET-2]
Q23. Let k = 2n. A circuit is built by giving the output of an n-bit binary counter as input
to an n-to-2n bit decoder. This circuit is equivalent to a
(a) k-bit binary up counter.
(b) k-bit binary down counter.
(c) k-bit ring counter.
(d) k-bit Johnson counter.
[Marks: 1 ][GATE: 2014] [ SET-2]
Q24. Consider the equation (123)5 = (x8)y with x and y as unknown. The number of
possible solutions is __________. [Marks: 1 ][GATE: 2014] [ SET-1]
The above sequential circuit is built using JK flip-flops is initialized with Q2Q1Q0
= 000. The
state sequence for this circuit for the next 3 clock cycle is
(a) 001, 010, 011 (b) 111, 110, 101
(c) 100, 110, 111 (d) 100, 011, 001
[Marks: 2][GATE: 2014] [ SET-3]
Q28. Let denote the Exclusive OR (XOR) operation. Let ‘1’ and ‘0’ denote the binary
constants. Consider the following Boolean expression for F over two variables P
and Q:F (P, Q) = ( ( 1 P) (P Q) ) ( (P Q) (Q 0) )
The equivalent expression for F is
(a) P + Q (b) (P + Q)’
(c) P Q (d) (P Q)’
[Marks: 2 ][GATE: 2014] [ SET-3]
Q29. Consider a 4 bit Johnson counter with an initial value of 0000. The counting
sequence of this counter is:
(a) 0, 1, 3, 7, 15, 14, 12, 8, 0 (b) 0, 1, 3, 5, 7, 9, 11, 13, 15, 0
(c) 0, 2, 4, 6, 8, 10, 12, 14, 0 (d) 0, 8, 12, 14, 15, 7, 3, 1, 0
[Marks: 1 ][GATE: 2015] [ SET-1]
Q30. A positive edge-triggered D flip-flop is connected to a positive edge-triggered JK
flipflop as follows. The Q output of the D flip-flop is connected to both the J and K
inputs of the JK flip-flop, while the Q output of the JK flip-flop is Connected to the
input of the D flip-flop. Initially, the output of the D flip-flop Is set to logic one and
the output of the JK flip-flop is cleared. Which one of the following is the bit
sequence (including the initial state) generated at the Q output of the JK flip-flop
when the flip-flops are connected to a free-running Common clock? Assume that
J = K = 1 is the toggle mode and J = K = 0 is the State-holding mode of the JK flip-
flop. Both the flip-flops have non-zero Propagation delays.
(A) 0110110… (B) 0100100…
(C) 011101110… (D) 011001100…
[Marks: 2 ][GATE: 2015] [ SET-1]
Q31. Consider the operations
f(X, Y, Z) = X’YZ + XY’ + Y’Z’ and g(X′, Y, Z) = X′YZ + X′YZ′ + XY
Which one of the following is correct?
(A) Both {f} and {g} are functionally complete
(B) Only {f} is functionally complete
(C) Only {g} is functionally complete
(D) Neither {f} nor {g} is functionally complete
[Marks: 2 ][GATE: 2015] [ SET-1]
Q32. The minimum number of JK flip-flops required to construct a synchronous counter
with the count sequence (0, 0, 1, 1, 2, 2, 3, 3, 0, 0,…….) is ___________.
[Marks: 1 ][GATE: 2015] [ SET-2]
Q33. The number of min-terms after minimizing the following Boolean expression
is________.[D′ + AB′ + A′C + AC′D + A′C′D]′
[Marks: 2 ][GATE: 2015] [ SET-2]
Q34. A half adder is implemented with XOR and AND gates. A full adder is implemented
with two half adders and one OR gate. The propagation delay of an XOR gate is
twice that of an AND/OR gate. The propagation delay of an AND/OR gate is 1.2
microseconds. A 4-bit ripple-carry binary adder is implemented by using four full
adders. The total propagation time of this 4-bit binary adder in microseconds is
____________
[Marks: 2 ][GATE: 2015] [ SET-2]
Q35. The total number of prime implicants of the function f(w, x, y, z) = Σ(0, 2, 4, 5, 6,
10) is______
[Marks: 2 ][GATE: 2015] [ SET-3]
Q36. Consider the Boolean operator # with the following properties: x#0 = x, x#1
= x’, x#x = and x#x’ = 1 Then x#y is equivalent to
(a) x’y + xy’ (b) xy’ + (xy) (c) x’y + xy (d) xy + (xy)’
[Marks: 1 ][GATE: 2016] [ SET-1]
Q37. The 16-bit 2’s complement representation of an integer is 1111 1111 1111 0101;
its decimal representation is ________ [Marks: 1 ][GATE: 2016] [ SET-1]
Q38. We want to design a synchronous counter that counts the sequence 0-1-0-2-0-3
and then repeats. The minimum number of J-K flip-flops required to implement
this counter is_____________ [Marks: 1 ][GATE: 2016] [ SET-1]
Q39. Consider the two cascaded 2-to-1 multiplexers as shown in the figure.
Assume for all inputs (a, c, d) the respective complements (a’, b’, c’, d’) are also
Available. The above logic is implemented 2-input NOR gates only. The Minimum
number of gates required is ____________.
[Marks: 1 ][GATE: 2017][ SET-1]
Q47. Consider a combination of T and D flip-flops connected as shown below. The
output of the D flipflop is connected to the input of the T flip-flop and the Output
of the T flip-flop is connected to the input of the D flip-flop.
Initially, both Q0 and Q1 are set to 1 (before the 1st clock cycle). The outputs
(a) Q1 Q0 after the 3rd cycle are 11 and after the 4th cycle are 00 respectively
(b) Q1 Q0 after the 3rd cycle are 11 and after the 4th cycle are 01 respectively
(c) Q1 Q0 after the 3rd cycle are 00 and after the 4th cycle are 11 respectively
(d) Q1 Q0 after the 3rd cycle are 01 and after the 4th cycle are 01 respectively
[Marks: 2][GATE: 2017][ SET-1]
Q48. The representation of the value of a 16-bit unsigned integer X in a hexadecimal
Number system is BCA9. The representation of the value of X in octal number
system is:
(a) 571244 (b) 736251 (c) 571247 (d) 136251
[Marks: 1][GATE: 2017][ SET-2]
Q49. If w, x, y, z are boolean variables, then which of the following in INCORRECT
(a) wx + w(x+y) + x(x+y) = x + wy
(b) (wx'(y + z’))’ + w’x = w’ + x + y’z
(c) (wx'(y + xz’) + w’x’)y = xy’
(d) (w + y)(wxy + wyz) = wxy + wyz [Marks: 2][GATE: 2017][ SET-2]
Q50. Given f(w, x, y, z) = Σm(0,1,2,3,7,8,10) + Σd(5,6,11,15), where d represents the
don’t-care condition in Karnaugh maps. Which of the following is a minimum
product-of-sums (POS) form of f (w, x, y, z)?
(a) f = (w’ + z’ )( x’ + z )
(b) f = (w’ + z ) ( x + z )
(c) f = ( w + z ) ( x ‘ + z )
(d) f = ( w + z’ ) ( x’ + z )[Marks: 2][GATE: 2017][ SET-2]
Q51. Given the following binary number in 32-bit (single precision) IEEE-754 format:
00111110011011010000000000000000
The decimal value closest to this floating-point number is
(a) 1.45 × 101
(b) 1.45 × 10-1
(c) 2.27 × 10-1
(d) 2.27 × 101
[Marks: 1][GATE: 2017][ SET-2]
Q52. The next state table of a 2-bit saturating up-counter is given below.
The number of states in the state transition diagram of this circuit that have a
Transition back to the same state on some value of “in” is ______ .
[Marks: 1][GATE: 2018]
Q56. Consider the unsigned 8-bit fixed point binary number representation below,
b7b6b5b4b3⋅ b2b1b0
where the position of the binary point is between b3 and b2 . Assume b7 is the
most significant bit. Some of the decimal numbers listed below cannot be
represented exactly in the above representation:
(i) 31.500 (ii) 0.875 (iii) 12.100 (iv) 3.001
Which one of the following statements is true?
(a) None of (i), (ii), (iii), (iv) can be exactly represented
(b) Only (ii) cannot be exactly represented
(c) Only (iii) and (iv) cannot be exactly represented
(d) Only (i) and (ii) cannot be exactly represented[Marks: 2][GATE: 2018]
Q57. Consider the minterm list form of a Boolean function F given below.
F(P, Q, R, S) = Σm(0, 2, 5, 7, 9, 11) + d(3, 8, 10, 12, 14)
Here, m denotes a minterm and d denotes a don’t care term. The number of
essential prime implicants of the function F is _______ . [Marks:
2][GATE: 2018]
Q58. Which one of the following is NOT a valid identity?
(a) (x ⊕ y) ⊕ z = x ⊕ (y ⊕ z)
(b) (x + y) ⊕ z = x ⊕ (y + z)
(c) x ⊕ y = x + y, if xy = 0
(d) x ⊕ y = (xy + x′y′)′
[Marks: 1][GATE: 2019]
Q59. Consider three 4-variable functions f1, f2 and f3, which are expressed in sum-of-
minterms
f1 = Σ(0, 2, 5, 8, 14)
f2 = Σ(2, 3, 6, 8, 14, 15)
f3 = Σ(2, 7, 11, 14)
For the following circuit with one AND gate and one XOR gate, the output function
f can be expressed as:
Which one of the following minterm lists represents the circuit given
above?[Marks: 2][GATE: 2020]
Q67. Consider three registers R1, R2 and R3 that store numbers in IEEE-754 single
precision floating point format. Assume that R1 and R2 contain the values (in
hexadecimal notation) 0x42200000 and 0xC1200000, respectively.
If R3 = R1/R2, what is the value stored in R3?
(a) 0x40800000 (b) 0x83400000 (c) 0xC8500000 (d) 0xC0800000
[Marks: 2][GATE: 2020]
Digital PYQs Answer key:
1. B 2. B 3. A 4. A 5. B
6. A 7. A 8. A 9. D 10. D
11. B 12. D 13. A 14. A 15. B
16. D 17. B 18. A 19. A 20. 5
21. A 22. D 23. C 24. 3 25.
26. 27. 28. 29. D 30.
31. A 32. 3 33. 1 34. 35.
36. A 37. -11 38. 4 39. 40. B
41. C 42. -1 43. 1 44. 45. D
46. 1 47. 48. A 49. C 50. A
51. C 52. B 53. 8 54. D 55. 2
56. C 57. A 58. B 59. A 60. 3
61. A 62. 0.502 63. D 64. 2020 65. 1034
66. C 67. D
GATE Computer Science & IT
GATE PAPERS
Compiler
(a) P-4. Q-1, R-2, S-3 (b) P-3, Q-1, R-4, S-2
(c) P-3, Q-4, R-1, S-2 (d) P-2, Q-1, R-4, S-3
[Marks: ][GATE: 2009]
Q2. Which data structure in a compiler is used for managing information about variables
I. Symbol table is accessed only during lexical analysis and syntax analysis.
II. Compilers for programming languages that support recursion necessarily need
heap storage for memory allocation in the run-time environment.
III. Errors violating the condition ‘any variable must be declared before its use’ are
detected during syntax analysis.
Which of the above statements is/are TRUE?
(a)II only (b)I only (c)I and III only (d)None of I, II and III
[Marks: ][GATE: 2020]
Syntax analysis
Q11. Which of the following statements are TRUE?
I.There exist parsing algorithms for some programming languages whose complexities
are less than q (n3 ).
II.A programming language which allows recursion can be implemented with static
storage III. No L-attributed definition can be evaluated in the framework of bottom-
up parsing.
IV. Code improving transformations can be performed at both source language and
intermediate code level
(a)I and II
(b)I and IV
(c)III and IV
(d)I, III and IV
[Marks: ][GATE: 2009]
Q12. The grammar S → aSa|bS|c is
Q13. Consider two binary operators and with the precedence of operator being lower
than that of the Operator Operatoris right associative while operator is left
associative. Which one of the following represents the parse tree for expression
(73 -4 -3 2)?
[Marks: 1][GATE:2011]
Q14. For the grammar below, a partial LL (1) parsing table is also presented along with
the grammar. Entries that need to be filled are indicated as E1, E2, and E3. Is the
empty string, $ indicates end of input, and, | separates alternate right hand sides of
productions.
The first and FOLLOW sets for the non-terminals A and B are
(a) (b)
FIRST(A) = {a,b,ε} = FIRST(B) FIRST(A) = {a,b,$}
FOLLOW(A) = {a,b} FIRST(B) = {a,b,ε}
FOLLOW(B) = {a,b,$} FOLLOW(A) = {a,b}
FOLLOW(B) = {$}
(c) (d)
FIRST(A) = {a,b,ε} = FIRST(B) FIRST(A) = {a,b} = FIRST(B)
FOLLOW(A) = {a,b} FOLLOW(A) = {a,b}
FOLLOW(B) = ∅ FOLLOW(B) = {a,b}
[Marks: 2][GATE: 2012]
Q15. The grammar. Entries that need to be filled are indicated as E1, E2, and E3. is the
Empty string, $ indicates end of input, and, | separates alternate right hand sides of
Productions.
[Marks:1][GATE: 2012]
Q16. What is the maximum number of reduce moves that can be taken by a bottom-up
parser for a grammar with no epsilon- and unit-production (i.e., of type A є and
Aa) to parse a string with n tokens?
(a) n/2 (b) n-1 (c) 2n-1 (d) 2n
[Marks: ][GATE: 2013]
Q17. 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.
(a) 1 only
(b) 2 only
(c) 1 and 4 only
(d) 1, 2, 3, and 4
[Marks:][GATE: 2013]
Q18. 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.
[Marks: ][GATE: 2014][SET-1]
Q19. Consider the grammar defined by the following production rules, with two operators
∗ and +
S --> T * P
T --> U | T * U
P --> Q + P | Q
Q --> Id
U --> Id
Which one of the following is TRUE?
(a)+ is left associative, while ∗ is right associative
(b)+ is right associative, while ∗ is left associative
(c)Both + and ∗ are right associative
(d)Both + and ∗ are left associative
[Marks: ][GATE: 2014][SET-2]
Q20. Which one of the following is True at any valid state in shift-reduce parsing?
(a) Viable prefixes appear only at the bottom of the stack and not inside
(b) Viable prefixes appear only at the top of the stack and not inside
(c) The stack contains only a set of viable prefixes
(d) The stack never contains viable prefixes
[Marks:1][GATE: 2015][SET-1]
Q21. Among simple LR (SLR), canonical LR, and look-ahead LR (LALR), which of the
following pairs identify the method that is very easy to implement and the method
that is the most powerful, in that order?
(a) SLR, LALR
(b) Canonical LR, LALR
(c) SLR, canonical LR
(d) LALR, canonical LR
[Marks:1 ][GATE: 2015][SET-3]
.
Q22. Consider the following grammar G.
S→F⎪H
F→p⎪c
H→d⎪c
Where S, F and H are non-terminal symbols, p, d and c are terminal symbols.Which
of the following statement(s) is/are correct?
S1: LL (1) can parse all strings that are generated using grammar G.
S2: LR (1) can parse all strings that are generated using grammar G.
(a) Only S1
(b) Only S2
(c) Both S1 and S2
(d) Neither S1 and S2
[Marks:2][GATE: 2015][SET-2]
Q23. The attributes of three arithmetic operators in some programming language are
given below.
p --> xQRS
Q -->yz|z
R --> w|∈
S -> y
(b) {w}
(c) {w, y}
(d) {w, ∉}
Which one of the following is correct for the given parse tree?
Compute the FOLLOW set of the non-terminal B and write the index values for the
symbols in the FOLLOW set in the descending order. (For example, if the FOLLOW
set is {a, b, d, $}, then the answer should be 3210)
(a)30
(b)31
(c)10
(d)20
[Marks: 1][GATE:2019]
Q30. Which one of the following kinds of derivation is used by LR parsers?
(a)Leftmost in reverse
(b)Rightmost in reverse
(c)Leftmost
(d)Rightmost
[Marks: 1][GATE:2019]
Q31. Consider the augmented grammar given below:
S' → S
S → 〈L〉 | id
L → L,S | S
Let I0 = CLOSURE ({[S' → ·S]}). The number of items in the set GOTO (I0 ,〈 ) is: ____.
[Marks:2][GATE:2019]
Q32. Consider the following grammar.
S->aSB| d
B->b
The number of reduction steps taken by a bottom-up parser while accepting the string
aaadbbb is _______. [Marks: ][GATE: 2020]
Syntax directed
Q33. Consider the expression tree shown. Each leaf represents a numerical value, which
can either be 0 or 1. Over all possible choices of the values at the leaves, the
Using the above SDTS, the output printed by a bottom-up parser, for the input aab is
(a) 1 3 2 (b) 2 2 3 (c) 2 3 1 (d)Syntax Error
[Marks: 2][GATE: 2016][SET-1]
Q35. Consider the following grammar and the semantic actions to support the inheriteatd
type declaration attributes. Let X1, X2, X3, X4, X5 and X6 be the placeholders for the non-
terminals D, T, L or L1 in the following table:
Which one of the following are the appropriate choices for X1, X2, X3 and X4?
(a) X1 = L, X2 = L, X3 = L1, X4 = T
(b) X1 = L, X2 = T, X3 = L1, X4 = L
(c) X1 = T, X2 = L, X3 = L1, X4 = T
(d) X1 = T, X2 = L, X3 = T, X4 = L1 [Marks:2][GATE:2019]
Q36. Consider the productions A⟶PQ and A⟶XY. Each of the five non-terminals A, P, Q,
a=1
b = 10
c = 20
d = a+b
e = c+d
f = c+e
b = c+e
e = b+f
d = 5+e
return d+f
Assuming that all operations take their operands from registers, what is the minimum
number of registers needed to execute this program without spilling?
(a)2
(b)3
(c)4
(d)6
[Marks: ][GATE: 2010]
Q38. Consider evaluating the following expression tree on a machine with load-store
architecture in which memory can be accessed only through load and store
instructions. The variables a, b, c, d and e initially stored in memory. The binary
operators used in this expression tree can be evaluate by the machine only when the
operands are in registers. The instructions produce results only in a register. If no
intermediate results can be stored in memory, what is the minimum number of
registers needed to evaluate this expression?
Q41. For a C program accessing X[i][j][k], the following intermediate code is generated by
a compiler. Assume that the size of an integer is 32 bits and the size of a character is 8
bits.
t0 = i ∗ 1024
t1 = j ∗ 32
t2 = k ∗ 4
t3 = t1 + t0
t4 = t3 + t2
t5 = X[t4]
Which one of the following statements about the source code for the C program is
CORRECT?
(a) X is declared as “int X[32][32][8]”
(b) X is declared as “int X[4][1024][32]”.
(c) X is declared as “char X[4][32][8]”.
(d) X is declared as “char X[32][16][2]”
[Marks:][GATE: 2014][SET-2]
Q42. One of the purposes of using intermediate code in compilers is to
static single assignment form for the expression q + r/3 + s – t * 5 + u * v/w is______.
[Marks: 2][GATE: 2015][SET-1]
Q46. In the context of abstract-syntax-tree (AST) and control-flow-graph (CFG), which one
of the following is TRUE?
(a) In both AST and CFG, let node, N2 be the successor of node N1. In the input
program, the code corresponding to N2 is present after the code corresponding in
N1 .
(b) For any input program, neither AST nor CFG will contain a cycle
(c) The maximum number of successors of a node in an AST and a CFG depends on
the input program
(d) Each node is AST and CFG corresponds to at most one statement in the input
program [Marks: ][GATE: 2015][SET-2]
Q47. Consider the following code segment.
x = u - t;
y = x * v;
x = y + w;
y = t - z;
y = x * y;
The minimum number of total variables required to convert the above code segment
to static single assignment form is
[Marks: 1][GATE: 2016][SET-1]
Q48. Consider the following grammar:
term → id | number
id → a|b| c
registers required by an optimal code generation (without any register spill) algorithm
for a load/store architecture, in which (i) only load and store instructions can have
memory operands and (ii) arithmetic instructions can have only register or immediate
operands. The value of X is ___________.
[Marks: 2][GATE: 2017][SET-1]
Code optim.
Q50. Which one of the following is FALSE?
(a) A basic block is a sequence of instructions where control enters the sequence at
the beginning and exits at the end.
(b) Available expression analysis can be used for common subexpression
elimination.
(c) Live variable analysis can be used for dead code elimination.
(d) x=4*5⇒x=20 is an example of common subexpression elimination.
[Marks: ][GATE: 2014][SET-1]
viable possibility?
(a) Neither L nor 𝐿̅is recursively enumerable (r.e.).
(b) One of L and 𝐿̅ is r.e. but not recursive; the other is not r.e.
(c) Both L and𝐿̅are r.e. but not recursive.
(d) Both L and 𝐿̅ are recursive.
[Marks:][GATE: 2014][SET-1]
Q56. Which of the regular expressions given below represent the following DFA?
I) 0*1(1+00*1)*
II) 0*1*1+11*0*1
III) (0+1)*1
[Marks:2][GATE: 2014][SET-1]
Least Recently Used (LRU) page replacement policy. Assume that all the page
frames are initially empty. What is the total number of page faults that will occur
while processing the page reference string given below? 4, 7, 6, 1, 7, 6, 1, 2, 7, 2
[Marks: 2][GATE: 2014][SET-3]
Q59. Let an represent the number of bit strings of length n containing two consecutive
[Marks:2][GATE: 2015][SET-3]
Q61. What will be the output of the following pseudo-code when parameters are passed
1. B 2. B 3. A 4. C 5. A
6. C 7. B 8. C 9. D 10. D
11. B 12. D 13. B 14. A 15. C
16. B 17. D 18. D 19. B 20. C
21. C 22. D 23. 9 24. B 25. C
26. A 27. C 28. A 29. B 30. B
31. 5 32. 7 33. 6 34. C 35. B
36. D 37. B 38. D 39. 4 40. B
41. A 42. C 43. C 44. A 45. 8
46. C 47. 10 48. A 49. 2 50. D
51. C 52. B 53. C 54. D 55. C
56. B 57. D 58. 6 59. A 60. A
61. D 62. B
GATE Computer Science
& IT
GATE PAPERS
TOC
(Topic-wise)
The above DFA accepts the set of all strings over {0,1} that
(a) begin either with 0 or 1
(b) end with 0
(c) end with 00
(d) contain the substring 00 [GATE - 2009]
Q2. Given the following state table of an FSM with two states A and B, one input and
one output.
If the initial state is A=0, B=0 what is the minimum length of an input string which
will take the machine to the state A=0, B=1 with output=1?
(a)3
(b)4
(c)5
(d)6
[GATE - 2009]
Q3. Which one of the following is FALSE?
(a) There is unique minimal DFA for every regular language.
(b) Every NFA can be converted to an equivalent PDA.
(c) Complement of every context-free language is recursive.
(e) Every non-deterministic PDA can be converted to an equivalent deterministic
PDA. [GATE - 2009]
Q4. Which one of the following languages over the alphabet {0, 1} is described by the
regular expression: (0 + 1)*0(0 + 1)*0(0 + 1)*? [GATE - 2009]
Q5. Let w be any string of length n is {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? [GATE – 2010]
(a) n – 1
(b) n
(c) n + 1
(d) 2n-1
Q6. What is the complement of the language accepted by the NFA shown below:
[Assume Σ={a} and ϵ is the empty string]
(a) ϕ
(b){ϵ}
(c) a∗
(d){a, ϵ}
[Marks: 1][GATE: 2012]
Q7. Consider the set of strings on {0, 1} in which, every substring of 3 symbols has at
most two zeros. For example, 001110 and 011001 are in the language, but
100010 is not. All strings of length less than 3 are also in the language. A partially
completed DFA that accepts this language is shown below.
What is the set of reachable states for the input string 0011?
(a){q0, q1, q2} (b) {q0, q1} (c) {q0, q1, q2, q3} (d){q3 }
[Marks: 1][GATE: 2014][SET-1]
Q10. Consider the following two statements:
I. If all states of an NFA are accepting states then the language accepted by the NFA is Σ*.
II. There exists a regular language A such that for all languages B, A∩B is regular.
Which one of the following is CORRECT?
(a) Only I is true
(b) Only II is true
(c) Both I and II are true
(d) Both I and II are false
[Marks:2][GATE: 2016][SET-2]
Q11. Let L = L1 ∩ L2, where L1 and L2 are languages as defined below:
L1 = {ambmcanbn∣m, n ≥0}
L2 = {aibjck ∣i, j, k≥0}
Then L is
(a) Not recursive
(b) Regular
(c) Context free but not regular
(d) Recursively enumerable but not context free.
Q12. Let L = {w ∈ (0 + 1)* | w has even number of 1s}, i.e. L is the set of all bit strings
with even number of 1s. Which one of the regular expression below represents L?
(a) (0* 10*1)*
(b) 0* (10*10*)*
(c) 0*(10*1*)*0*
(d) 0*1(10*1)*10*
[Marks: 2][GATE: 2010]
Q13. Given the language L = {ab, aa, baa}, which of the following strings are in L*? 1)
abaabaaabaa 2) aaaabaaaa 3) baaaaabaaaab 4) baaaaabaa
(a)1, 2 and 3
(b)2, 3 and 4
(c)1, 2 and 4
(d)1, 3 and 4
[Marks:1][GATE: 2012]
Q14. Which one of the following regular expressions represents the set of all binary
strings with an odd number of 1’s?
(a) ((0 + 1)*1(0 + 1)*1)*10*
(b) (0*10*10*)*0*1
(c) 10*(0*10*10*)*
(d) (0*10*10*)*10*
[Gate - 2020]
Q15. The length of the shortest string NOT in the language (over Σ = {a, b}) of the
following regular expression is ______________.
Q16. Which one of the following regular expressions represents the language: the set of all
binary strings having two consecutive 0s and two consecutive 1s?
(a) (0 + 1)* 0011(0 + 1)* + (0 + 1)* 1100(0 + 1)*
(b) (0 + 1)* (00(0 + 1)* 11 + 11(0 + 1)* 00)(0 + 1)*
(c) (0 + 1)* 00(0 + 1)* + (0 + 1)* 11(0 + 1)*
(d) 00(0 + 1)* 11 + 11(0 + 1)* 00
[Marks:1][GATE: 2016][SET-1]
Q19. Let L1 be a recursive language. Let L2 and L3 be languages that are recursively
enumerable but not recursive. Which of the following statements is not
necessarily true?
(a) L2 – L1 is recursively enumerable
(b) L1 – L3 is recursively enumerable
(c) L2 ∩ L1 is recursively enumerable
(d) L2 ∪ L1 is recursively enumerable [Marks: 1][GATE: 2010]
Context-free language
Q20. Consider the languages
L1 = {0i1j | i != j}.
L2 = {0i1j | i = j}.
L3 = {0i1j | i = 2j+1}.
L4 = {0i1j | i != 2j}.
Which one of the following statements is true?
(a) Only L2 is context free
(b) Only L2 and L3 are context free
(c) Only L1 and L2 are context free
(d) All are context free [Marks: 2][GATE: 2010]
Q21. Let P be a regular language and Q be context-free language such that Q ⊆ P.
(For example, let P be the language represented by the regular expression
p*q* and Q be {pnqn| n ∈N}). Then which of the following is ALWAYS regular?
(a) P ∩ Q (b) P – Q (c) ∑* – P (d) ∑* – Q
[GATE – 2011]
Q22. Consider the languages L1, L2 and L3 as given below.
L1 = {0p1q∣ p, q ∈ N},
L2 = {0p1q∣ p, q ∈ N and p = q} and
L3 = {0p1q0r ∣ p, q, r ∈ N and p = q = r}.
Which of the following statements is NOT TRUE?
(a) Push Down Automata (PDA) can be used to recognize L1 and L2
(b) L1 is a regular language
(c) All the three languages are context free
(d) Turing machines can be used to recognize all the languages
[Marks: 2][GATE: 2011]
Q23. Consider the following languages over the alphabet ∑ = {0, 1, c}
L1 = {0n1n∣n≥0}
L2 = {wcwr ∣w ∈{0, 1}*}
L3 = {wwr∣w ∈{0, 1}*}
Here, wr is the reverse of the string w. Which of these languages are
deterministic Context-free languages?
(a) None of the languages (b) Only L1
(c) Only L1 and L2 (d) All the three languages
[Marks: 2][GATE: 2014][SET-3]
Q24. Which of the following languages are context-free?
L1 = {ambnanbm⎪ m, n ≥ 1}
L2 = {ambnambn⎪ m, n ≥ 1}
L3 = {ambn⎪ m = 2n + 1}
(a) L1 and L2 only
(b) L1 and L3 only
(c) L2 and L3 only
(d) L3 only
[Marks: ][GATE: 2015][SET-3]
Q25. Consider the following languages:
L1 = {an bmcn+m: m, n ≥ 1}
L2 = {an bn c2n : n ≥ 1}
Which one of the following isTRUE?
(a) Both L1 and L2 are context-free.
(b) L1 is context-free while L2 is not context-free.
(c) L2 is context-free while L1 is not context-free.
(d) Neither L1 nor L2 is context-free.
[Marks:2][GATE: 2016][SET-2]
Q26. Consider the following languages:
I. {ambncpdq∣ m + p = n + q, where m, n, p, q ≥ 0}
II. {ambncpdq∣ m = n and p = q, where m, n, p, q ≥ 0}
III. {ambncpdq∣ m = n = p and p ≠ q, where m, n, p, q ≥ 0}
IV. {ambncpdq∣ mn = p + q, where m, n, p, q ≥ 0}
Which of the above languages are context-free?
(a)I and IV only
(b)I and II only
(c)II and III only
(d)II and IV only [Marks: 2][GATE: 2018]
Q27. Which one of the following languages over Σ = {a, b} is NOT context-free?
(a) {wwR |w ∈ {a,b}*}
(b) {wanbnwR |w ∈ {a,b}*, n ≥ 0}
(c) {wanwRbn |w ∈ {a,b}*, n ≥ 0}
(d) {anbi | i ∈ {n, 3n, 5n}, n ≥ 0} [Marks: 2][GATE: 2019]
Q28. Consider the language L = {an ∣n ≥ 0 }∪{anbn ∣ n ≥ 0 } and the following statements.
I. L is deterministic context-free.
II. L is context-free but not deterministic context-free.
III. L is not LL(k) for any k.
Which of the above statements is/are TRUE? [Gate CS: 2020]
(a)Ⅰonly (b) Ⅱonly (c) Ⅰ& II only (d) III only
Q31. A deterministic finite automation (DFA)D with alphabet {a, b} is given below
Which of the following finite state machines is a valid minimal DFA which
accepts the same language as D?
[Marks: 2][GATE: 2011]
Q32. Consider the DFAs M and N given above. The number of states in a minimal DFA
that accepts the language L(M) ∩ L(N) is __________.
Which one of the following sequences must follow the string 101100 so that the
overall string is accepted by the automaton?
(a)10110 (b)10010 (c) 01010 (d)01001
[Marks: 2][GATE: 2015][SET-1]
Arden’s lemma
Q61. Consider the alphabet Σ={0,1}, the null/empty string λ and the set of strings X0,X1, and X2
generated by the corresponding non-terminals of a regular grammar. X0, X1, and X2 are related
as follows.
X0=1X1
X1=0X1+1X2
X2=0X1+ λ
Which one of the following choices precisely represents the strings in X0?
(a) 10(0∗+(10)∗)1
(b) 10(0∗+(10)∗)∗1
(c) 1(0+10)∗1
(d) 10(0+10)∗1+110(0+10)∗1
[Marks: 2][GATE: 2015][SET-2]
Context-free language and context-free grammars
Q62. Which of the following languages is generated by the given grammar?
S → aS|bS|ε
(a) {anbm |n,m ≥ 0}
(b) {w ∈ {a, b}* | w has equal number of a’s and b’s}
(c) {an |n ≥ 0}∪{bn |n ≥ 0}∪{an b(sup>n|n≥ 0}
(d) {a, b}* [Marks:1][GATE: 2016][SET-1]
Q65. Let L(R) be the language represented by regular expression R. Let L(G) be the
language generated by a context free grammar G. Let L(M) be the language
accepted by a Turing machine M.
Which of the following decision problems are undecidable? I.
Given a regular expression R and a string w, is w ∈ L(R)?
II. Given a context-free grammar G, is L(G) = ∅?
(b) L = {an |n≥0} ∪ {anbn|n≥ 0} and is not accepted by any deterministic PDA
(c) L is not accepted by any Turing machine that halts on every input
[Marks:2][GATE: 2016][SET-1]
Q69. The number of states in the minimum sized DFA that accepts the language
defined by the regular expression. (0+1)*(0+1)(0+1)* is ________
[Marks:1][GATE: 2016][SET-2]
Closure properties
Q70. Consider the following types of languages:
L1: Regular,
L2: Context-free,
L3: Recursive,
L4: Recursively enumerable.
Which of the following is/are TRUE?
(I) ̅̅̅
𝐿3 ∪ 𝐿4 is recursively enumerable.
(II) ̅̅̅
𝐿2 ∪ 𝐿3 is recursive.
(III) L*1 ∩L2 is context-free.
(IV) L1 ∪ ̅̅̅
𝐿2 is context-free.
(a) I only.
(b) I and III only.
(c) I and IV only.
(d) I, II and III only.
[Marks:1][GATE: 2016][SET-2]
Q71. Let L1, L2 be any two context-free languages and R be any regular language. Then which of
the following is/are CORRECT?
a. L1∪ L2 is context-free.
b. L1' is context-free.
c. L1 – R is context-free.
d. L1∩ L2 context-free. [Marks:1][GATE: 2017][SET-2]
(d) I only
Decidable and not decidable
Q72. Consider the following languages.
L1 = {〈M〉|M takes at least 2016 steps on some input},
L2 = {〈M〉│M takes at least 2016 steps on all inputs} and
L3 = {〈M〉|M accepts ε};
Where for each Turing machine M, 〈M〉 denotes a specific encoding of M. Which one of the
following is TRUE?
(A) L1 is recursive and L2, L3 are not recursive
(B) L2 is recursive and L1, L3 are not recursive
(C) L1, L2 are recursive and L3 is not recursive
(D) L1, L2, L3 are recursive
[Marks:2][GATE: 2016][SET-2]
Context-free grammars
Q73. A student wrote two context-free grammars G1 and G2 for generating a single C-
like array declaration. The dimension of the array is at least one. For example,
int a[10][3];The grammars use D as the start symbol, and use six terminal
symbols int; id[] num.
[Marks:2][GATE: 2017][SET-1]
Context-free grammars to context-free language
Q75. Consider the following context-free grammar over the alphabet Σ = {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)n (cb)n│n≥ 1}
(b) {(ab)ncb(m1 ) cb(m2 )…cb(mn )│n, m1, m2, …, mn ≥ 1}
(c) {(ab)n (cbm)n│m,n≥ 1}
(d) {(ab)n (cbn)m│m,n≥ 1}
[Marks:1][GATE: 2017][SET-1]
Q76. Consider the context-free grammars over the alphabet {a, b, c} given below. S
and T are non-terminals.
Q77. Identify the language generated by the following grammar, where S is the start
variable. S
→ XY, X → aX| a, Y → aYb | ϵ
[Marks:2][GATE: 2017][SET-1]
NFA
Q80. Let 𝛿 denote the transition function and 𝛿̂ denote the extended transition function of the ∈
−𝑁𝐹𝐴 whose transition table is shown below:
L2 = {an bm c2m | n ≥ 0, m ≥ 0}
L3 = {an bn c2n │ n ≥ 0}
L4 = {an bn│ n ≥ 1}
Context-free language
78. D 79. C 80. C 81. C 82. B
83. B 84. B 85. C 86. C 87. B
Minimization of DFA
88. B 89. A 90. 1 91. 3 92. 5
93. 4 94. 8 95. D 96. 6 97. A
Regular language
98. C 99. A 100. A 101. A 102. C
103. B
119. C
Context-free language and context-free grammars
120. D 121. D
Decidability and un-decidability
126. D
Regular expression and minimization
127. 2
Closure properties
128. D 129. B
Decidable and not decidable
130. C
Context-free grammars
131. A 132. D
Context-free grammars to context-free language
136. A
Recursive and recognizable language
137. A
NFA
138. C
Context-free and regular language
139. D 140. C
Closure properties of recognizable language
83. B
84. 2
Pumping lemma for regular language
85. D
Closure properties of regular language
86. D
ADA PYQ
Q1. Consider a binary max-heap implemented using an array. What is the content of the array
after two delete operations on {25,14,16,13,10,8,12}
(a) {14,13,12,10,8}
(b) {14,12,13,8,10}
(c) {14,13,12,8,10}
(d) {14,13,8,12,10}
Q2. What is the maximum height of any AVL-tree with 7 nodes? Assume that the height of a
tree with a single node is 0.
(a)2 (b)3 (c)4 (d)5
[Marks: ][GATE: 2009]
Q3. The keys 12,18,13,2,3,23,5 and 15 are inserted into an initially empty hash table of length
10 using open addressing with hash function h(k)=kmod10 and linear probing. What is
the resultant hash table?
[Marks: ][GATE: 2009]
Q4. In a binary tree with n nodes, every node has an odd number of descendants. Every
node is considered to be its own descendant. What is the number of nodes in the tree
that have exactly one child?
(a)0 (b)1 (c)(n-1)/2 (d)n-1
[Marks: ][GATE: 2010]
Q5. The following C function takes a singly-linked list as input argument. It modifies the list
by moving the last element to the front of the list and returns the modified list. Some part
of the code is left blank.
typedef struct node
{
int value;
struct node *next;
} node;
Node *move_to-front(Node *head)
{
Node *p, *q;
if ((head == NULL) || (head -> next == NULL))
return head;
q = NULL;
p = head;
while (p->next != NULL)
{
q=p;
p=p->next;
}
_______________
return head;
}
Choose the correct alternative to replace the blank line.
(a) q=NULL;p→next=head;head=p;
(b) q→next=NULL;head=p;p→next=head;
(c) head=p;p→next=q;q→next=NULL;
(d) q→next=NULL;p→next=head;head=p; [Marks: ][GATE: 2009]
Q6. Consider a complete undirected graph with vertex set {0, 1, 2, 3, 4}. Entry Wij in the
matrix W below is the weight of the edge {i, j}. What is the minimum possible weight of
a spanning tree T in this graph such that vertex 0 is a leaf node in the tree T?
Which one of the following choices gives a possible order in which the key values could
have been inserted in the table?
(A) 46, 42, 34, 52, 23, 33
(B) 34, 42, 23, 52, 33, 46
(C) 46, 34, 42, 23, 52, 33
(D) 42, 46, 33, 23, 34, 52
[Marks: 1][GATE: 2010]
Q8. A hash table of length 10 uses open addressing with hash function h(k)=kmod10, and
linear probing. After inserting 6 values into an empty hash table, the table is shown as
below
How many different insertion sequences of the key values using the same hash function
and linear probing will result in the hash table shown above?
(a)10 (b)20 (c)30 (d)40
[Marks: 2][GATE: 2010]
Q9. Two alternative packages A and B are available for processing a database having 10k
records.Package A requires 0.0001n2 time units and package B requires 10nlog10n
time units to process n records. What is the smallest value of k for which package B
will be preferred over A?
(a) 12 (b) 10 (c) 6 (d) 5
[Marks: 1][GATE: 2010]
Q10. The weight of a sequence a0, a1, …, an-1 of real numbers is defined as a0+a1/2+…+
aa-1/2n-1. A subsequence of a sequence is obtained by deleting some elements from
the sequence, keeping the order of the remaining elements the same. Let X denote the
maximum possible weight of a subsequence of a0, a1, …,an-1 and Y the maximum
possible weight of a subsequence of a1, a2, …,an-1. Then X is equal to
(a) max(Y, a0+Y) (b) max(Y, a0+Y/2)
(c) max(Y, a0+2Y) (d) a0+Y/2
[Marks: 1][GATE: 2010]
Q11. A max-heap is a heap where the value of each parent is greater than or equal to the
value of its children. Which of the following is a max-heap?
[Marks: 1][GATE: 2011]
Q12. An algorithm to find the length of the longest monotonically increasing sequence of
numbers in an array A[0:n−1] is given below. Let Li, denote the length of the longest
monotonically increasing sequence starting at index i in the array.
1 + Li + 1if A[i] < 𝐴[𝑖 + 1]
Li={
1 Otherwise
Initialize Ln−1=1.
Finally, the length of the longest monotonically increasing sequence is
max(L0,L1,…,Ln−1). Which of the following statements is TRUE?
(a) The algorithm uses dynamic programming paradigm
(b) The algorithm has a linear complexity and uses branch and bound paradigm
(c) The algorithm has a non-linear polynomial complexity and uses branch and bound
paradigm
(d) The algorithm uses divide and conquer paradigm
Q13. We are given a set of n distinct elements and an unlabelled binary tree with n nodes.
In how many ways can we populate the tree with the given set so that it becomes a
binary search tree?
(a) 0
(b) 1
(c) n!
(d) (1/(n+1)).2nCn
Q14. Which of the given options provides the increasing order of asymptotic complexity of
functions f1, f2, f3 and f4?
f1(n) = 2^n
f2(n) = n^(3/2)
f3(n) = nLogn
f4(n) = n^(Logn)
(a) f3, f2, f4, f1 (b) f3, f2, f1, f4
(C) f2, f3, f1, f4 (d) f2, f3, f4, f1
[Marks:2 ][GATE: 2011]
Q15. Four matrices M1, M2, M3 and M4 of dimensions pxq, qxr, rxs and sxt respectively can be
multiplied is several ways with different number of total scalar multiplications. For
example, when multiplied as ((M1 X M2) X (M3 X M4)), the total number of
multiplications is pqr + rst + prt. When multiplied as (((M1 X M2) X M3) X M4), the total
number of scalar multiplications is pqr + prs + pst.
If p = 10, q = 100, r = 20, s = 5 and t = 80, then the number of scalar multiplications
needed is:
(A) 248000
(B) 44000
(C) 19000
(D) 25000
Q16. The worst case running time to search for an element in a balanced binary search tree
with n2n elements is
(a)Θ (n log n)
(b)Θ (n log n)
(c)Θ (n)
(d)Θ (log n)
Q17. The recurrence relation capturing the optimal execution time of the Towers of Hanoi
problem with n discs is
(a) T(n) = 2T(n - 2) + 2
(b) T(n) = 2T(n - 1) + n
(c) T(n) = 2T(n/2) + 1
(d) T(n) = 2T(n - 1) + 1
[Marks:1 ][GATE: 2012]
Q19. 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.
Q21. Let W(n) and A(n) denote respectively, the worst case and average case running time of
an algorithm executed on an input of size n. Which of the following is ALWAYS TRUE?
(A) A(n) = Ω (W(n)) (B) A(n) = Θ (W(n))
(C) A(n) = O (W(n)) (D) A(n) = o (W(n))
Q22. Which one of the following is the tightest upper bound that represents the number of
swaps required to sort n numbers using selection sort?
(A) O(log n) (B) O(n) (C) O(n log n) (D) O(n2)
[Marks: 1][GATE: 2013]
Q23. Which one of the following is the tightest upper bound that represents the time complexity
of inserting an object into a binary search tree of n nodes?
(A) O(1) (B) O(log n) (C) O(n) (D) O(n log n)
[Marks: 2][GATE: 2013]
Q24. What is the time complexity of Bellman-Ford single-source shortest path algorithm on a
complete graph of n vertices?
(A) Θ(n2) (B) Θ(n2log n) (C) Θ(n3) (D) Θ(n3log n)
[Marks: 2][GATE: 2013]
Q25. The number of elements that can be sorted in Θ (log n) time using heap sort is
int i, j, k=0;
for (i=n/2; i<=n; i++)
for (j=2; j<=n; j=j*2)
k = k + n/2;
return (k);
}
The return value of the function is
(a) Θ(n2) (b) Θ(n2logn) (c)Θ(n3) (d)Θ(n3logn)
Q27. The preorder traversal sequence of a binary search tree is 30, 20, 10, 15, 25, 23, 39, 35,
42. Which one of the following is the postorder traversal sequence of the same tree?
(A) 10, 20, 15, 23, 25, 35, 42, 39, 30
(B) 15, 10, 25, 23, 20, 42, 35, 39, 30
(C) 15, 20, 10, 23, 25, 42, 35, 39, 30
(D) 15, 10, 23, 25, 20, 35, 42, 39, 30
Q28. 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 > 0) {
Dequeue(Q)
m=m–1
}
}
What is the worst case time complexity of a sequence of n queue operations on an initially
empty queue?
(a) Θ(n)
(b) Θ(n + k)
(c) Θ(nk)
(d) Θ(n2)
Q29. Let G be a graph with n vertices and m edges. What is the tightest upper bound on the
running time of Depth First Search on G, when G is represented as an adjacency matrix?
(a)θ(n)
(b)θ(n+m)
(c)θ(n2 )
(d)θ(m2 )
[Marks:1 ][GATE: 2014][SET-1]
Q30. Consider a rooted n node binary tree represented using pointers. The best upper bound
on the time required to determine the number of subtrees having exactly 4 nodes is
O(nalogbn). Then the value of a+10b is ________.
[Marks: 1][GATE: 2014][SET-1]
Q31. Consider the directed graph given below. Which one of the following is TRUE?
Q32. Let P be a quicksort program to sort numbers in ascending order using the first elements
as the 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=5 (b) t12 (c) t1>t2 (d) t1=t2
Q34. Consider the following C function in which size is the number of elements in the array E:
int MyX(int *E, unsigned int size)
{
int Y = 0;
int Z;
int i, j, k;
Q37. Consider a 6-stage instruction pipeline, where all stages are perfectly balanced. Assume
that there is no cycle-time overhead of pipelining. When an application is executing on
this 6-stage pipeline, the speedup achieved with respect to non-pipelined execution if 25%
of the instructions incur 2 pipeline stall cycles is ______________________.
[Marks: 1][GATE: 2014][SET-1]
Q38. An access sequence of cache block addresses is of length N and contains n unique block
addresses. The number of unique block addresses between two consecutive accesses to
the same block address is bounded above by k. What is the miss ratio if the access
sequence is passed through a cache of associativity A≥k exercising least-recently-used
replacement policy?
(a) n/N
(b) 1/N
(c) 1/A
(d) k/n [Marks:1][GATE: 2014][SET-1]
Q39. A priority queue is implemented as a Max-Heap. Initially, it has 5 elements. The level-
order traversal of the heap is: 10, 8, 5, 3, 2. Two new elements 1 and 7 are inserted into
the heap in that order. The level-order traversal of the heap after the insertion of the
elements is:
(a)10, 8, 7, 3, 2, 1, 5
(b)10, 8, 7, 2, 3, 1, 5
(c)10, 8, 7, 1, 2, 3, 5
(d)10, 8, 7, 5, 3, 2, 1
now consider that a value 35 is inserted into this heap. After insertion, the new heap is
(a)40, 30, 20, 10, 15, 16, 17, 8, 4, 35
(b)40, 35, 20, 10, 30, 16, 17, 8, 4, 15
(c)40, 30, 20, 10, 35, 16, 17, 8, 4, 15
(d)40, 35, 20, 10, 15, 16, 17, 8, 4, 30
[Marks:2][GATE: 2015][SET-1]
Q44. Which of the following is/are correct inorder traversal sequence(s) of binary search
tree(s)?
I. 3, 5, 7, 8, 15, 19, 25
II. 5, 8, 9, 12, 10, 15, 25
III. 2, 7, 10, 8, 14, 16, 20
IV. 4, 6, 7, 9 18, 20, 25
(A) I and IV only
(B) II and III only
(C) II and IV only
(D) II only
Q45. What are the worst-case complexities of insertion and deletion of a key in a binary search
tree?
(A) θ (log)for both insertion and deletion
(B) θ (n)for both insertion and deletion
(C) θ (n)for insertion and θ (log)n deletion
(D) θ (log n)for insertion and θ(n) for deletion
Q46. Match the following:
(A) P-iii, Q-ii, R-iv, S-i
(B) P-i, Q-ii, R-iv, S-iii
(C) P-ii, Q-iii, R-iv, S-i
(D) P-ii, Q-i, R-iii, S-iv [Marks: 2][GATE: 2015][SET-1]
Q47. Let an represent the number of bit strings of length n containing two consecutive 1s.
What is the recurrence relation for an?
Q48. An algorithm performs (log N)1/2 find operations, Ninsert operations, (logN)1/2delete
operations, and (log N)1/2decrease-key operations on a set of data items with keys drawn
from a linearly ordered set. For a delete operation, a pointer is provided to the record that
must be deleted. For the decrease-key operation, a pointer is provided to the record that
has its key decreased. Which one of the following data structures is the most suited for
the algorithm to use, if the goal is to achieve the best total asymptotic complexity
considering all the operations?
(A) Unsorted array
(B) Min-heap
(C) Sorted array
(D) Sorted doubly linked list
Q52. Consider a complete binary tree where the left and the right subtrees of the root are
max-heaps. The lower bound for the number of operations to convert the tree to a heap
is
(a) Ω(log𝑛) (b) Ω(𝑛) (c) Ω(𝑛log𝑛) (d) Ω(𝑛2)
Q53. A binary tree T has 20 leaves. The number of nodes in T having two children is_____.
[Marks: ][GATE: 2015][SET-2]
Q54. Given below are some algorithms, and some algorithm design paradigms.
Match the above algorithms on the left to the corresponding design paradigm they follow.
(a) 1-i, 2-iii, 3-i, 4-v.
(b) 1-iii, 2-iii, 3-i, 4-v.
(c) 1-iii, 2-ii, 3-i, 4-iv.
(d) 1-iii, 2-ii, 3-i, 4-v.
Q55. A Young tableau is a 2D array of integers increasing from left to right and from top to
bottom. Any unfilled entries are marked with ∞, and hence there cannot be any entry to
the right of, or below a ∞. The following Young tableau consists of unique entries.
When an element is removed from a Young tableau, other elements should be moved into
its place so that the resulting table is still a Young tableau (unfilled entries may be filled
in with a ∞). The minimum number of entries (other than 1) to be shifted, to remove 1
from the given Young tableau is ______________.
Q56. Suppose you are provided with the following function declaration in the C programming
language.
int partition(int a[], int n);
The function treats the first element of a[] as a pivot, and rearranges the array so that all
elements less than or equal to the pivot is in the left part of the array, and all elements
greater than the pivot is in the right part. In addition, it moves the pivot so that the pivot
is the last element of the left part. The return value is the number of elements in the left
part.
The following partially given function in the C programming language is used to find the
𝑘𝑡hsmallest element in an array a[] of size n using the partition function. We assume 𝑘≤𝑛.
int kth_smallest(int a[], int n, int k)
{ int left_end = partition(a,n);
if ( left_end+1 == k ){
return a[left_end]; }
if ( left_end+1 > k ){
return kth_smallest( _____________________ );
} else {
return kth_smallest( _____________________ );
}
}
The missing argument lists are respectively
(A) (a, left_end, k) and (a+left_end+1, n-left_end-1, k-left_end-1)
(B) (a, left_end, k) and (a, n-left_end-1, k-left_end-1)
(C) (a+left_end+1, n-left_end-1, k-left_end-1) and (a, left_end, k)
(D) (a, n-left_end-1, k-left_end-1) and (a, left_end, k)
Q57. Which one of the following hash functions on integers will distribute keys most uniformly
over 10 buckets numbered 0 to 9 for 𝑖𝑖 ranging from 0 to 2020?
(A) ℎ(𝑖)= 𝑖2 mod 10
(B) ℎ(𝑖)= 𝑖3 mod 10
(C) ℎ(𝑖)=(11∗𝑖2) mod 10
(D) ℎ(𝑖)=(12∗𝑖) mod 10
Q58. Assume that the bandwidth for a TCP connection is 1048560 bits/sec. Let α be the value
of RTT in milliseconds. (rounded off to the nearest integer) after which the TCP window
scale option is needed. Let β be the maximum possible window size the window scale
option. Then the values of α and β are
(a) 63 milliseconds, 65535×214
(b) 63 milliseconds, 65535×216
(c) 500 milliseconds, 65535×214
(d) 500 milliseconds, 65535×216
[Marks: 2][GATE: 2015][SET-2]
Q59.Given a hash table T with 25 slots that stores 2000 elements, the load factor α for T is
___________.
[Marks: 1][GATE: 2015][SET-3]
Q60. Consider the equality ∑𝑛𝑖=0 𝑖 3 = X and the following choice for X
i. (n4)
ii. (n5)
iii. 0 (n5)
iv. (n3)
The equality above remains correct if X is replaced by
A. Only I
B. Only II
C. I or III or IV but not II
D. II or III or IV but not I
Q61. While inserting the elements 71, 65, 84, 69, 67, 83 in an empty binary search tr
element in the lowest level is _____________________
(B) 6
Q63. Consider a binary tree T that has 200 leaf nodes. Then, the number of nodes in T that
have exactly two children are ________.
Q67. Assume that a mergesort algorithm in the worst case takes 30 seconds for an input of size
64. Which of the following most closely approximates the maximum input size of a
problem that can be solved in 6 minutes?
(A) 256
(B) 512
(C) 1024
(D) 2048
Q68. Let an be the number of n-bit strings that do NOT contain two consecutive 1′s. Which
one of the following is the recurrence relation for an?
(a) an=an−1+2an−2
(b) an=an−1+an−2
(c) an=2an−1+an−2
(d) an=2an−1+2an−2
[Marks:1][GATE: 2016][SET-1]
Q69. A queue is implemented using an array such that ENQUEUE and DEQUEUE operations
are performed efficiently. Which one of the following statements is CORRECT (n refers
to the number of items in the queue)?
(a) Both operations can be performed in O(1) time
(b) At most one operation can be performed in O(1) time but the worst case time for the
other operation will be Ω(n)
(c) The worst case time complexity for both operations will be Ω(n)
(d) Worst case time complexity for both operations will be Ω(logn)
[Marks:1][GATE: 2016][SET-1]
The number of different topological orderings of the vertices of the graph is _______.
(a)7 (b)8 (c)9 (d)6
[Marks:1][GATE: 2016][SET-1]
Q71. The worst case running times of Insertion sort, Merge sort and Quick sort, respectively,
are:
(a) Θ(n log n), Θ(n log n) and Θ(n2)
(b) Θ(n2), Θ(n2) and Θ(n Log n)
(c) Θ(n2), Θ(n log n) and Θ(n log n)
(d) Θ(n2), Θ(n log n) and Θ(n2)
[Marks:1][GATE: 2016][SET-1]
Q72. Let G be a weighted connected undirected graph with distinct positive edge weights. If
every edge weight is increased by the same value, then which of the following statements
is/are TRUE?
P: Minimum spanning tree of G does not change
Q: Shortest path between any pair of vertices does not change
(a)P only (b)Q only
(c)Neither P nor Q (d)Both P and Q
(a) [Marks:1][GATE: 2016][SET-1]
Q73. An operator delete(i) for a binary heap data structure is to be designed to delete the Item
in the i-th node. Assume that the heap is implemented in an array and i refers tothe i-th
index of the array. If the heap tree has depth d (number of edges on the path from the root
to the farthest leaf), then what is the time complexity to re-fix the heap efficiently after the
removal of the element?
(a) O(1)
(b) O(d) but not O(1)
(c) O(2d) but not O
(d) O(d 2d) but not O(2d)
[Marks:2][GATE: 2016][SET-1]
Q74. Consider the recurrence relation a1 = 8, an = 6n2 + 2n + 1. Let a99 = k x 104. The value of
K is ____ Marks:2][GATE: 2016][SET-1]
Q75. Consider the weighted undirected graph with 4 vertices, where the weight of edge {i,j}
The largest possible integer value of x, for which at least one shortest path between some
pair of vertices will contain the edge with weight x is _________.
[Marks:2][GATE: 2016][SET-1]
Q76. Let Q denote a queue containing sixteen numbers and S be an empty stack. Head(Q)
returns the element at the head of the queue Q without removing it from Q. Similarly
Top(S) returns the element at the top of S without removing it from S. Consider the
algorithm given below.
[Marks:2][GATE: 2016][SET-1]
Q77. Breadth First Search (BFS) is started on a binary tree beginning from the root vertex.
There is a vertex t at a distance four from the root. If t is the n-th vertex in this BFS
traversal, then the maximum possible value of n is _________.
[Marks:1][GATE: 2016][SET-2]
Q78. Assume that the algorithms considered here sort the input sequences in ascending order.
If the input is already in ascending order, which of the following are TRUE ?
I. Quicksort runs in Θ(n2) time
II. Bubblesort runs in Θ(n2) time
III. Mergesort runs in Θ(n) time
IV. Insertion sort runs in Θ(n) time
(a) I and II only
(b) I and III only
(c) II and IV only
(d) I and IV only
[Marks:1][GATE: 2016][SET-2]
Q79. N items are stored in a sorted doubly linked list. For a delete operation, a pointer is
provided to the record to be deleted. For a decrease-key operation, a pointer is provided
to the record on which the operation is to be performed.An algorithm performs the
following operations on the list in this order: Θ(N) delete,O(logN) insert, O(logN) find,
and Θ(N) decrease-key. What is the time complexity of all these operations put together?
(a)O(log2 N)
(b)O(N)
(c)O(N2)
(d)Θ(N2 logN)
[Marks:1][GATE: 2016][SET-2]
Q80. The Floyd-Warshall algorithm for all-pair shortest paths computation is based on:
(a) Greedy paradigm.
(b) Divide-and-Conquer paradigm.
(c) Dynamic Programming paradigm.
(d) neither Greedy nor Divide-and-Conquer nor Dynamic Programming paradigm
[Marks:1][GATE: 2016][SET-2]
Q81. A complete binary min-heap is made by including each integer in [1, 1023] exactly once.
The depth of a node in the heap is the length of the path from the root of the heap to that
node. Thus, the root is at depth 0. The maximum depth at which integer 9 can appear is
_________.
[Marks:2][GATE: 2016][SET-2]
Q82. Consider the following New-order strategy for traversing a binary tree:
Visit the root;
Visit the right subtree using New-order;
Visit the left subtree using New-order;
The New-order traversal of the expression tree corresponding to the reverse polish
expression 3 4 * 5 - 2 ˆ 6 7 * 1 + - is given by:
(a) + - 1 6 7 * 2 ˆ 5 - 3 4 *
(b) - + 1 * 6 7 ˆ 2 - 5 * 3 4
(c) - + 1 * 7 6 ˆ 2 - 5 * 4 3
(d) 1 7 6 * + 2 5 4 3 * - ˆ -
[Marks:2][GATE: 2016][SET-2]
Q83. The number of ways in which the numbers 1, 2, 3, 4, 5, 6, 7 can be inserted in an empty
binary search tree, such that the resulting tree has height 6, is _________.
Note: The height of a tree with a single node is 0.
[Marks:2][GATE: 2016][SET-2]
Q84. In an adjacency list representation of an undirected simple graph G = (V,E), each edge
(u,v) has two adjacency list entries: [v] in the adjacency list of u, and [u] in the adjacency
list of v. These are called twins of each other. A twin pointer is a pointer from an adjacency
list entry to its twin. If |E| = m and |V| = n, and the memory size is not a constraint,
what is the time complexity of the most efficient algorithm to set the twin pointer in each
entry in each adjacency list?
(a)Θ(n2)
(b)Θ(n+m)
(c)Θ(m2)
(d)Θ(n4)
[Marks:2][GATE: 2016][SET-2]
while (b != 0) {
if (b % 2 == 0) {a = a * a; b = b/2; }
else {res = res * a; b = b - 1; }
}
return res;
}
Which one of the following conditions is TRUE before every iteration of the loop?
a) XY=ab
b) (res ∗ a)Y=(res ∗ X)b
c) XY=res ∗ ab
d) XY=(res ∗ a)b
[Marks:2][GATE: 2016][SET-2]
Q86. Let A1, A2, A3, and A4 be four matrices of dimensions 10 x 5, 5 x 20, 20 x 10, and 10
x 5, respectively. The minimum number of scalar multiplications required to find the
product A1A2A3A4 using the basic matrix multiplication method is._________
[Marks:2][GATE: 2016][SET-2]
Q87. The given diagram shows the flowchart for a recursive function A(n). Assume that
allstatements, except for the recursive calls, have O(1) time complexity. If the worst
casetime complexity of this function is O(nα), then the least possible value (accurate up
totwo decimal positions) of α is ________.
[Marks:1][GATE: 2017][SET-1]
Q89. Let T be a tree with 10 vertices. The sum of the degrees of all the vertices in T is
_________.
[Marks:1][GATE: 2017][SET-1]
Q90. Consider the following functions from positives integers to real numbers
Match the algorithm to design paradigms they are based on:(a) P-(ii), Q-(iii), R-(i)
(b) P-(iii), Q-(i), R-(ii)(c) P-(ii), Q-(i), R-(iii) (d)
P-(i), Q-(ii), R-(iii)
[Marks:1][GATE: 2017][SET-1]
Q92. Let T be a binary search tree with 15 nodes. The minimum and maximum possible heights
of T are: Note: The height of a tree with a single node is 0.
Q94. The Breadth First Search (BFS) algorithm has been implemented using the queue data
structure. Which one of the following is a possible order of visiting the nodes in the
graph below?
[Marks:1][GATE: 2017][SET-2]
Q95. The pre-order traversal of a binary search tree is given by 12, 8, 6, 2, 7, 9, 10, 16, 15, 19,
17, 20. Then the post-order traversal of this tree is:
(a)2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20
(b)2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12
(c)7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12
(d)7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12
[Marks:2][GATE: 2017][SET-2]
(a) P→(iii)Q→(iv)r→(i)S→(ii)
(b) P→(iv)Q→(iii)r→(i)S→(ii)
(c) P→(iii)Q→(iv)r→(ii)S→(i)
(d)P→(iv)Q→(iii)r→(ii)S→(i)
[Marks:1][GATE: 2017][SET-2]
Q97. Consider the following C function.
int fun(int n)
int i, j;
for (j = 1; j < n; j += i)
[Marks:2][GATE: 2017][SET-2]
(a) Θ(loglogn)
(b) Θ(logn)
(c) Θ(√𝑁)
(d) Θ(n)
[Marks:2][GATE: 2017][SET-2]
Q99. A message is made up entirely of characters from the set X={P,Q,R,S,T}. The table of
probabilities for each of the characters is shown below:
If a message of 100 characters over X is encoded using Huffman coding, then the expected
length of the encoded message in bits is ______.
[Marks:2][GATE: 2017][SET-2]
Q100. The postorder traversal of a binary tree is 8, 9, 6, 7, 4, 5, 2, 3, 1. The inorder traversal of
the same tree is 8, 6, 9, 4, 7, 2, 5, 1, 3. The height of a tree is the length of the longest path
from the root to any leaf. The height of the binary tree above is _______.
[Marks:1][GATE: 2018]
Q101. A queue is implemented using a non-circular singly linked list. The queue has a head
pointer and a tail pointer, as shown in the figure. Let n denote the number of nodes in the
queue. Let 'enqueue' be implemented by inserting a new node at the head, and 'dequeue'
be implemented by deletion of a node from the tail.
Which one of the following is the time complexity of the most time-efficient
implementation of 'enqueue' and 'dequeue, respectively, for this data structure?
(a)θ(1), θ(1)
(b)θ(1), θ(n)
(c)θ(n), θ(1)
(d)θ(n), θ(n)
[Marks:1][GATE: 2018]
Q102. Let G be a simple undirected graph. Let TD be a depth first search tree of G. Let TB be a
breadth first search tree of G. Consider the following statements.
(I) No edge of G is a cross edge with respect to TD.(A cross edge in G is between two
nodes neither of which is an ancestor of the other in T D.)
(II) For every edge (u,v) of G, if u is at depth i and v is at depth j in TB, then ∣i−j∣ = 1.
Q103. The number of possible min-heaps containing each value from {1, 2, 3, 4, 5, 6, 7} exactly
once is ___________.
[Marks: 2][GATE: 2018]
Q106. Consider the weights and values of items listed below. Note that there is only one unit
Ofeach item.
The task is to pick a subset of these items such that their total weight is no more than 11
Kgsand their total value is maximized. Moreover, no item may be split. The total value
of itemspicked by an optimal algorithm is denoted by 𝑉opt. A greedy algorithm sorts the
items by their value-to-weight ratios in descending order and packs them greedily, starting
from the first item in the ordered list. The total value of items picked by the greedy
algorithm is denoted by 𝑉greedy.
The value of 𝑉opt−𝑉greedy is ____________.
[Marks: 2][GATE: 2018
Q107. Let T be a full binary tree with 8 leaves. (A full binary tree has every level full). Suppose
two leaves a and b of T are chosen uniformly and independently at random.
The expected value of the distance between a and b in T (i.e., the number of edges in
the unique path between a and b) is (rounded off to 2 decimal places) _____.
[Marks:2 ][GATE: 2019]
Q108. An array of 25 distinct elements is to be sorted using quicksort. Assume that the pivot
element is chosen uniformly at random. The probability that the pivot element gets placed
in the worst possible location in the first round of partitioning (rounded off to 2 decimal
places) is _________. [Marks:1 ][GATE: 2019]
Q109. Consider a sequence of 14 elements: A=[−5,−10,6,3,−1,−2,13,4,−9,−1,4,12,−3,0]. The
𝐽
sequence sum S(i,j)= ∑𝐾=1 𝐴[𝐾] . Determine the maximum of S(i,j), where 0≤i≤j<14.
(Divide and conquer approach may be used.) [Marks: 1][GATE: 2019]
Q110. There are n unsorted arrays: A1,A2,…,An. Assume that n is odd.Each of A1,A2,…,An
contains n distinct elements. There are no common elements between any two arrays.
The worst-case time complexity of computing the median of the medians of A1,A2,…,An
is
(a) O(n) (b) O(nlogn) (c) O(n2) (d) Ω(n2logn)
[Marks: 2][GATE: 2019]
Q111. Consider the following statements:
I. The smallest element in a max-heap is always at a leaf nod
II. The second largest element in a max-heap is always a child of a root node
III. A max-heap can be constructed from a binary search tree in Θ(n) time
IV. A binary search tree can be constructed from a max-heap in Θ(n) time
Which of the above statements are TRUE?
(a) Θ(logalogbn)
(b) Θ(logabn)
(c)Θ(logblogan)
(d) Θ(log2log2n)
Q115. What is the worst case time complexity of inserting n elements into an empty linked list,
if the linked list needs to be maintained in sorted order ?
(A) Θ(n)
(B) Θ(n log n)
(C) Θ(n2)
(D) Θ(1)
[Marks:1 ][GATE: 2020]
Q116. Consider the following C program.
#include
int main () {
int a [4] [5] = {{1, 2, 3, 4, 5},
{6, 7, 8, 9, 10},
{11, 12, 13, 14, 15},
{16, 17, 18, 19, 20}};
printf (“%d\n”, *(* (a+**a+2) +3));
return (0);
}
The output of the program is _______.
Q117. What is the worst case time complexity of inserting n2 elements into an AVL-tree with
n elements initially ?
(a) Θ(n4)
(b) Θ(n2)
(c) Θ(n2 log n)
(d) Θ(n3) [Marks:1 ][GATE: 2020]
Q118. In a balanced binary search tree with n elements, what is the worst case time complexity
of reporting all elements in range [a,b]? Assume that the number of reported elements is
k.
(a) Θ(logn) (b) Θ(logn+k) (c) Θ(klogn) (d)Θ(nlogk)
[Marks:2 ][GATE: 2020]
Q119. Consider the array representation of a binary min-heap containing 1023 elements. The
minimum number of comparisons required to find the maximum in the heap is _______.
[Marks:2 ][GATE: 2020]
Q120. Let G=(V,E) be a weighted undirected graph and let T be a Minimum Spanning Tree
(MST) of G maintained using adjacency lists. Suppose a new weighed edge (u,v)∈V×V is
added to G. The worst case time complexity of determining if T is still an MST of the
resultant graph is
(a) Θ(∣E∣+∣V∣) (b) Θ(∣E∣∣V∣) (c)Θ(E∣log∣V∣) (d)Θ(∣V∣)
[Marks:2 ][GATE: 2020]
Q121. Let T be a binary search tree with 15 nodes. The minimum and maximum possible heights
of T are:
Note: The height of a tree with a single node is 0.
(a)4 and 15 respectively
(b)3 and 14 respectively
(c)4 and 14 respectively
(d)3 and 15 respectively
[Marks: ][GATE: 2017][SET-1]
1. C 2. B 3. C 4. A 5. D
6. D 7. C 8. C 9. C 10. B
11. B 12. A 13. B 14. A 15. C
16. C 17. D 18. A 19. D 20. A
21. C 22. B 23. C 24. C 25. C
26. B 27. D 28. A 29. C 30. 1
31. C 32. C 33. A 34. A 35. C
36. 148 37. 4 38. A 39. A 40. B
41. A 42. B 43. B 44. A 45. B
46. C 47. A 48. A 49. D 50. D
51. D 52. D 53. 19 54. C 55. 5
56. A 57. B 58. C 59. 80 60. C
61. B 62. 142 63. 199 64. D 65. 0
66. D 67. B 68. B 69. A 70. 6
71. D 72. A 73. 74. 198 75. 12
76. 256 77. 31 78. 79. C 80. C
81. 8 82. C 83. 64 84. B 85. C
86. 1500 87. 2.2 to 2.4 88. B 89. 18 90. B
91. C 92. C 93. B 94. D 95. B
96. C 97. C 98. B 99. 225 100. 4
101. B 102. A 103. 80 104. C 105. 10230
106. 16 107. 4.25 108. 0.08 109. 29 110. C
111. A 112. A 113. B 114. 13 115. C
116. 19 117. C 118. B 119. 511 120. D
121. B
Discrete mathematics
Q2. What is the chromatic number of an n-vertex simple connected graph which does
not contain any odd length cycle? Assume n ≥ 2.
(a)2 (b)3 (c)n-1 (d)n
[Marks: ][GATE: 2009]
Q4. Consider the binary relation R = {(x, y), (x, z), (z, x), (z, y)} on the set {x, y, z}.
Which one of the following is TRUE?
(a) R is symmetric but NOT anti-symmetric
(b) R is NOT symmetric but anti-symmetric
(c) R is both symmetric and anti-symmetric
(d) R is neither symmetric nor anti-symmetric
[Marks: ][GATE: 2009]
Q5. An unbalanced dice (with 6 faces, numbered from 1 to 6) is thrown. The
probability that the face value is odd is 90% of the probability that the face value
is even. The probability of getting any even numbered face is the same. If the
probability that the face is even given that it is greater than 3 is 0.75, which one
of the following options is closest to the probability that the face value exceeds
3?
(a) 0.453 (b) 0.468 (c) 0.485 (d) 0.492
[Marks: ][GATE: 2009]
Q6. For the composition table of a cyclic group shown below correct?
Q7. Which one of the following is the most appropriate logical formula to represent
the statement?
“Gold and silver ornaments are precious”.
The following notations are used:
G(x): x is a gold ornament,
S(x): x is a silver ornament,
P(x): x is precious
(a) ∀x(P(x) → (G(x) ∧ S(x)))
(b) ∀x((G(x) ∧ S(x)) → P(x))
(c) ∃x((G(x) ∧ S(x)) → P(x)
(d) ∀x((G(x) ∨ S(x)) → P(x)) [Marks: ][GATE: 2009]
Q16. Consider a complete undirected graph with vertex set {0, 1, 2, 3, 4}. Entry Wij in
the matrix W below is the weight of the edge {i, j}.
What is the minimum possible weight of a spanning tree T in this graph such
that vertex 0 is a leaf node in the tree T?
(a) 7 (b) 8 (c) 9 (d) 10
[Marks: 2][GATE: 2010]
Q17. 1 2𝑛
What is the value of lim (1 − ) ?
𝑛→∞ 𝑛
(a)0 (b)e-2
(c) e-1/2 (d)1
[Marks: ][GATE: 2010]
Q18. Consider a company that assembles computers. The probability of a faulty
assembly of any computer is p. The company therefore subjects each computer
to a testing process. This testing process gives the correct result for any computer
with a probability of q. What is the probability of a computer being declared
faulty?
(a)pq + (1 - p)(1 - q) (b)(1 - q)p
(c)(1 - p)q (d)pq
(a)[Marks: ][GATE: 2010]
Q19. What is the probability that divisor of 1099 is a multiple of 1096?
(a)1/625 (b)4/625
(c)12/625 (d) 16/625
[Marks: ][GATE: 2010]
Q20. 2 3
Consider the following matrix 𝐴 = [ ] If the eigenvalues of A are 4 and 8,then
𝑥 𝑦
(a)x=4, y=10
(b)x=5, y=8
(c)x=-3, y=9
(d)x=-4, y=10
[Marks: ][GATE: 2010]
Q22. Which one of the following options is CORRECT given three positive integers x, y
and z, and a predicate?
P(x) = ¬(x = 1) ∧ ∀y (∃z (x = y * z) ⇒ (y = x) ∨ (y = 1))
(a) P(x) being true means that x is a prime number
(b) P(x) being true means that x is a number other than 1
(c) P(x) is always true irrespective of the value of x
(d) P(x) being true means that x has exactly two factors other than 1 and x
[Marks:][GATE: 2011]
Q23. An undirected graph G (V, E) contains n (n > 2) nodes named v1, v2 ,….vn.
Two nodes vi, vj are connected if and only if 0 < |i – j| <= 2. Each edge (vi, vj) is
assigned a weight i + j. A sample graph with n = 4 is shown below.
What will be the cost of the minimum spanning tree (MST) of such a graph with
n nodes?
(a)11 n2 – 5
(b) n2 – n + 1
(c) 6n – 11
(d) 2n + 1 [Marks: 2][GATE:2011]
Q24. An undirected graph G (V, E) contains n (n > 2) nodes named v1 , v2 ,….vn. Two
nodes vi , vj are connected if and only if 0 < |i – j| <= 2. Each edge (vi, vj) is
assigned a weight i + j. A sample graph with n = 4 is shown below.
The length of the path from v5 to v6 in the MST of previous question with n = 10
is
(a) 11
(b) 25
(c) 31
(d) 41 [Marks: 2][GATE: 2011]
Q25. If the difference between the expectation of the square of a random variable
(E[X2]) and the square of the expectation of the random variable (E[X2]) is denoted
by R, then
(a) R = 0
(b) R < 0
(c) R ≥ 0
(d) R > 0
[Marks: ][GATE: 2011]
Q26. Consider the matrix as given below Which one of the following provides the
CORRECT values of eigenvalues of the matrix?
1 2 3
[0 4 7]
0 0 3
(a) 1, 4, 3
(b) 3, 7, 3
(c) 7, 3, 2
(d) 1, 2, 3
[Marks: ][GATE: 2011]
Q27. Given i=√−1what will be the evaluation of the definite integral∫0
𝜋/2 cos 𝑥+𝑖 𝑠𝑖𝑛𝑥
dx ?
cos 𝑥−𝑖𝑠𝑖𝑛 𝑥
Q31. What is the correct translation of the following statement into mathematical
logic?
“Some real numbers are rational”
(a) ∃x(real(x)∨rational(x))
(b) ∀x(real(x)→rational(x))
(c) ∃x(real(x)∧rational(x))
(d) ∃x(rational(x)→real(x)) [Marks:1][GATE: 2012]
Q32. Let G be a simple undirected planar graph on 10 vertices with 15 edges. If G is a
connected graph, then the number of bounded faces in any embedding of G on
the plane is equal to
(a) 3 (b) 4 (c) 5 (d) 6
[Marks: 1][GATE: 2012]
Q33. Which of the following graphs is isomorphic to
Q35. How many onto (or surjective) functions are there from an n-element (n >= 2) set
to a 2-element set?
(a) 2n (b) 2n – 1 (c) 2n – 2 (d) 2(2n – 2)
[Marks:2][GATE: 2012]
Q36. Let G be a complete undirected graph on 6 vertices. If vertices of G are labeled,
then the number of distinct cycles of length 4 in G is equal to
(a) 15 (b) 30 (c) 90 (d) 360
[Marks:2][GATE: 2012]
Q37. 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.
Q38. Consider the function f(x) = sin(x) in the interval x ∈ [π/4, 7π/4]. The number
and location(s) of the local minima of this function are
(a) One, at π/2
(b) One, at 3π/2
(c) Two, at π/2 and 3π/2
(d) Two, at π/4 and 3π/2
[Marks:][GATE: 2012]
Q39. Let A be the 2×2 matrix with elements a11 = a12 = a21 = +1 and a22 = -1. Then the
eigenvalues of the matrix A19 are
(a)1024 and -1024
(b)1024√2 and -1024√2
(c)4√2 and -4√2
(d)512√2 and -512√2
[Marks:][GATE: 2012]
Q40. Consider a random variable X that takes values +1 and −1 with probability 0.5
each. The values of the cumulative distribution function F(x) at x = −1 and +1
are
(a)0 and 0.5
(b)0 and 1
(c)0.5 and 1
(d)0.25 and 0.75
[Marks:][GATE: 2012]
Q41. Suppose a fair six-sided die is rolled once. If the value on the die is 1, 2, or 3,
the die is rolled a second time. What is the probability that the sum total of
values that turn up is at least 6?
(a)10/21
(b)5/12
(c)2/3
(d)1/6
[Marks:][GATE: 2012]
Q42. A binary operation on a set of integers is defined as x y = x2 + y2. Which one
of the following statements is TRUE about ?
(a) Commutative but not associative
(b) Both commutative and associative
(c) Associative but not commutative
(d) Neither commutative nor associative [Marks: 1][GATE: 2013]
Q43. Which of the following statements is/are TRUE for undirected graphs?
P: Number of odd degree vertices is even.
Q: Sum of degrees of all vertices is even.
(a) P only
(b) Q only
(c) Both P and Q
(d) Neither P nor Q [Marks:1][GATE: 2013]
Q44. The line graph L(G) of a simple graph G is defined as follows:
There is exactly one vertex v(e) in L(G) for each edge e in G.
For any two edges e and e’ in G, L(G) has an edge between v(e) and v(e’), if and
only if e and e’ are incident with the same vertex in G.
Which of the following statements is/are TRUE?
(P) The line graph of a cycle is a cycle.
(Q) The line graph of a clique is a clique.
(R) The line graph of a planar graph is planar.
(S) The line graph of a tree is a tree.
(a) P only
(b) P and R only
(c) R only
(d) P, Q and S only [Marks:2][GATE: 2013]
Q47. 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/(2e3) (b)9/(2e3) (c)17/(2e3) (d) 26 /(2e3)
[Marks: ][GATE: 2013]
Q48. Which one of the following does NOT equal to?
1 𝑥 𝑥2
|1 𝑦 𝑦2|
1 𝑧 𝑧2
(a) (b)
1 𝑥 (𝑥 + 1) 𝑥+1 1 (𝑥 + 1) 𝑥 2 + 1
|1 𝑦 ( 𝑦 + 1) 𝑦 + 1| |1 ( 𝑦 + 1) 𝑦 2 + 1|
1 𝑧 (𝑧 + 1) 𝑧+1 1 (𝑧 + 1) 𝑧 2 + 1
(c) (d)
0 𝑥−𝑦 𝑥2 − 𝑦2 2 (𝑥 + 𝑦) 𝑥2 + 𝑦2
|0 𝑦−𝑧 𝑦2 − 𝑧2 | |2 ( 𝑦 + 𝑧) 𝑦2 + 𝑧2 |
1 𝑧 𝑧2 1 𝑧 𝑧2
[Marks:][GATE: 2013]
[Marks:][GATE: 2013]
.
Q50. Consider the statement: "Not all that glitters is gold”
Predicate glitters(x) (x) is true if xx glitters and predicate gold(x) (x) is true
if xx is gold. Which one of the following logical formulae represents the above
statement?
Q53. Let S denotes the set of all functions f :{ 0, 1}4→ {0, 1}. Denote by N the number
of functions from S to the set {0, 1}. The value of log2 log 2 N is ______
[Marks:2][GATE: 2014][SET-1]
Q54. An ordered n-tuple (d1, d2, … , dn) with d1 d2 ⋯ dn is called graphic if
there exists a simple undirected graph with n vertices having degrees d 1, d2,
… , dn respectively. Which of the following 6-tuples is NOT graphic?
(a) (1, 1, 1, 1, 1, 1)
(b) (2, 2, 2, 2, 2, 2)
(c) (3, 3, 3, 1, 0, 0)
(d) (3, 2, 1, 1, 1, 0)
[Marks: 2][GATE: 2014][SET-1]
Q55. Which one of the following propositional logic formulas is TRUE when exactly two
of p, q and r are TRUE?
(a)((p ↔ q) ∧ r) ∨ (p ∧ q ∧ ∼r)
(b)(∼(p ↔ q) ∧ r) ∨ (p ∧ q ∧ ∼r)
(c)((p → q) ∧ r) ∨ (p ∧ q ∧ ∼r)
(d)(∼(p ↔ q) ∧ r) ∧ (p ∧ q ∧ ∼r)
[Marks:2][GATE:
2014][SET-1]
Q56. Let G = (V, E) be a directed graph where V is the set of vertices and E the set of
edges. Then which one of the following graphs has the same strongly connected
components as G?
(a)G1 = (V, E1) where E1 = {(u, v)|(u, v)∉E}
(b)G2 = (V,E2 )where E2={(u, v)│(u, v)∈E}
(c)G3 = (V,E3) where E3={(u, v)|there is a path of length≤2 from u to v in E}
(d)G4 = (V4,E) where V4 is the set of vertices in G which are not isolated
[Marks:2][GATE: 2014][SET-1]
Q57. The value of the dot product of the eigenvectors corresponding to any pair of
different eigenvalues of a 4-by-4 symmetric positive definite matrix is
_____________________. [Marks: ][GATE: 2014][SET-1]
Q58. Let the function
𝜋 𝜋
θ∈[ , ]and f′(θ) denote the derivative of f with respect to θ. Which of the
6 3
Q65. The number of distinct minimum spanning trees for the weighted graph below is
_____
[Marks:][GATE: 2014][SET-2]
Q73. The probability that a given positive integer lying between 1 and 100 (both
inclusive) is NOT divisible by 2, 3 or 5 is ______ .
(a)0.259 to 0.261
(b)0.260 to 0.262
(c)0.261 to 0.263
(d)0.262 to 0.264
[Marks:][GATE: 2014][SET-2]
[Marks:][GATE: 2014][SET-3]
Q76. Let X and Y be finite sets and f: X→Y be a function. Which one of the following
statements is TRUE? [GATE: 2014][SET-3]
Q79. There are two elements x, y in a group (G,∗) such that every element in the
group can be written as a product of some number of x's and y's in some order.
It is known that x*x = y*y = x*y*x*y = y*x*y*x = e; where e is the identity
element. The maximum number of elements in such a group is ____.
[Marks:2][GATE: 2014][SET-3]
Q80. If G is the forest with n vertices and k connected components, how many edges
does G have?
(a)⌊n/k⌋ (b)⌈n/k⌉ (c)n – k (d) n – k + 1
[Marks:2][GATE: 2014][SET-3]
Q81. Let d denote the minimum degree of a vertex in a graph. For all planar graphs
on n vertices with d ≥ 3, which one of the following is TRUE?
(a) In any planar embedding, the number of faces is at least n/2 + 2
(b) In any planar embedding, the number of faces is less than n/2 + 2
(c) There is a planar embedding in which the number of faces is less than n/2
+2
(d) There is a planar embedding in which the number of faces is at most
n/(d+1)
[Marks:2][GATE: 2014][SET-3]
Q82. Let δ denote the minimum degree of a vertex in a graph. For all planar graphs on
n vertices with δ ≥3, which one of the following is TRUE?
𝑛
(a) In any planar embedding, the number of faces is at least +2
2
𝑛
(b) In any planar embedding, the number of faces is less than +2
2
𝑛
(c) There is a planar embedding in which the number of faces is less than +2
2
𝑛
(d) There is a planar embedding in which the number of faces is at most
δ+1
[Marks:][GATE: 2014][SET-3]
Q83. The CORRECT formula for the sentence, "not all Rainy days are Cold" is
(a) ∀𝑑(𝑅𝑎𝑖𝑛𝑦(𝑑) ∧ ~𝐶𝑜𝑙𝑑 (𝑑))
(b) ∀𝑑(~𝑅𝑎𝑖𝑛𝑦(𝑑) → 𝐶𝑜𝑙𝑑 (𝑑))
(c) ∃𝑑(~𝑅𝑎𝑖𝑛𝑦(𝑑) → 𝐶𝑜𝑙𝑑 (𝑑))
(d) ∃𝑑(𝑅𝑎𝑖𝑛𝑦(𝑑) ∧ ~𝐶𝑜𝑙𝑑(𝑑)) [GATE: 2014][SET-3]
Q84. Which one of the following statements is TRUE about every n × n matrix with
only real eigenvalues?
(a) If the trace of the matrix is positive and the determinant of the matrix is
negative, at least one of its eigenvalues is negative.
(b) If the trace of the matrix is positive, all its eigenvalues are positive.
(c) If the determinant of the matrix is positive, all its eigenvalues are positive.
(d) If the product of the trace and determinant of the matrix is positive, all its
eigenvalues are positive.
[Marks:][GATE: 2014][SET-3]
Q85. If V1 and V2 are 4-dimensional subspaces of a 6-dimensional vector space V, then
the smallest possible dimension of V1∩V2 is ______.
(a)2
(b)3
(c)4
(d)5
[GATE: 2014][SET-3]
Q86. 2𝜋
If ∫0 |𝑥 𝑠𝑖𝑛 𝑥|𝑑𝑥 = k𝜋, then the value of K is equal to _____________.
[Marks:][GATE: 2014][SET-3]
𝜋
Q87. The value of the integral given below is∫0 𝑥 2 𝑐𝑜𝑠 𝑥𝑑𝑥
(A)-2π
(B) π
(C)- π
(D)2 π
[Marks:][GATE: 2014][SET-3]
Q88. Let S be a sample space and two mutually exclusive events A and B be such
that A∪B = S. If P(∙) denotes the probability of the event, the maximum value of
P(A)P(B) is __________.
(a)0.25 (b)0.26 (c)0.27 (d)0.28
[GATE: 2014][SET-3]
Q89. Consider the set of all functions f:{0, 1 …2014}→{0, 1 … 2014} such that f(f(i)) =
i, for all 0 ≤ i ≤ 2014. Consider the following statements:
P. For each such function it must be the case that for every i, f(i) = i.
Q. For each such function it must be the case that for some i, f(i) = i.
R. Each function must be onto.
Which one of the following is CORRECT?
(a) P, Q and R are true
(b) Only Q and R are true
(c) Only P and Q are true
(d) Only R is true
[Marks:][GATE: 2014][SET-3]
Q90. If g (X) =1− x and h (x) =
𝑥
, then
𝑔(ℎ(𝑥))
is
𝑥−1 ℎ(𝑔(𝑥))
ℎ(𝑥)
(a)
𝑔(𝑥)
−1
(b)
𝑥
𝑔(𝑥)
(c)
ℎ(𝑥)
𝑥
(d)
(1−𝑥)2
[GATE: 2015][SET-1]
Q91. Which one of the following is NOT equivalent to p ↔ q?
(𝑎)(¬𝑝 ∨ 𝑞) ∧ (𝑝 ∨ ¬𝑞)
(𝑏)(¬𝑝 ∨ 𝑞) ∧ (𝑞 → 𝑝)
(c)(¬𝑝 ∧ 𝑞) ∨ (𝑝 ∧ ¬𝑞)
For any x, y ∈ L, not necessarily distinct, x ∨ y and x ∧ y are join and meet of x,
y respectively. Let L3 = {(x, y, z): x, y, z ∈ L} be the set of all ordered triplets of
the elements of L. Let pr be the probability that an element (x, y, z) ∈ L3 chosen
equiprobably satisfies x ∨ (y ∧ z) = (x ∨ y) ∧ (x ∨ z). Then
1 1
(a) Pr = 0 (b) Pr = 1 (c) 0 < Pr ≤ (d) < Pr< 1
5 5
[GATE: 2015][SET-1]
Q95. Let G be a connected planar graph with 10 vertices. If the number of edges on
each face is three, then the number of edges in G is_______________.
[Marks:][GATE: 2015][SET-1]
Q96. The graph shown below has 8 edges with distinct integer edge weights. The
minimum spanning tree (MST) is of weight 36 and contains the edges:
{(A, C), (B, C), (B, E), (E, F), (D, F)}. The edge weights of only those edges which
are in the MST are given in the figure shown below. The minimum possible sum
of weights of all 8 edges of this graph is_______________.
[Marks:][GATE: 2015][SET-1]
Q102. ∑99 1
𝑋=1 _______________________
𝑥(𝑥+1)
Q103. Let 𝑅 be the relation on the set of positive integers such that 𝑎Rb if and only if 𝑎
and 𝑏 are distinct and have a common divisor other than 1. Which one of the
following statements about 𝑅 is true?
(a) 𝑅 is symmetric and reflexive but not transitive
(b) 𝑅 is reflexive but not symmetric and not transitive
(c) 𝑅 is transitive but not reflexive and not symmetric
(d) 𝑅 is symmetric but not reflexive and not transitive
[Marks:][GATE: 2015][SET-2]
.
Q104. The number of onto functions (surjective functions) from set 𝑋 = {1, 2, 3, 4} to set
𝑌 = {𝑎, b, c} is __________ [Marks:][GATE: 2015][SET-2]
Q105. Let 𝑋 and 𝑌 denote the sets containing 2 and 20 distinct objects respectively and
𝐹 denotes the set of all possible functions defined from 𝑋 to 𝑌. Let 𝑓 be randomly
chosen from 𝐹. The probability of 𝑓 being one-to-one is ________.
[Marks:][GATE: 2015][SET-2]
Q106. A graph is self-complementary if it is isomorphic to its complement. For all self-
complementary graphs on 𝑛 vertices, 𝑛 is
(a) A multiple of 4
(b) Even
(c) Odd
(d) Congruent to 0 𝑚od 4, or, 1 𝑚od 4. [GATE: 2015][SET-2]
[Marks:][GATE: 2015][SET-2]
Q113. Let 𝑓(𝑥) = 𝑥 (−1/3) and A denote the area of the region bounded by f(x) and the X-
axis, when x varies from -1 to 1. Which of the following statements is/are TRUE?
I) f is continuous in [-1,1]
II) f is not bounded in [-1,1]
III) A is nonzero and finite
(a)II only (b)III only (c)II and III only (d)I, II and III
[Marks:][GATE: 2015][SET-2]
Q114. Suppose 𝑈 is the power set of the set 𝑆 = {1, 2, 3, 4, 5, 6}. For any 𝑇∈𝑈, let |𝑇|
denote the number of elements in 𝑇 and 𝑇′ denote the complement of 𝑇. For any
𝑇∈𝑈, let 𝑇∖𝑅 be the set of all elements in 𝑇 which are not in 𝑅. Which one of the
following is true?
(a) ∀𝑋 ∈ 𝑈 (|𝑋| = |𝑋′|)
(𝑏) ∃𝑋 ∈ 𝑈 ∃𝑌 ∈ 𝑈 (|𝑋| = 5, |𝑌| = 5 𝑎𝑛𝑑 𝑋 ∩ 𝑌 = ∅)
(𝑐) ∀𝑋 ∈ 𝑈 ∀𝑌 ∈ 𝑈 (|𝑋| = 2, |𝑌| = 3 𝑎𝑛𝑑 𝑋 ∖ 𝑌 = ∅)
(𝑑) ∀𝑋 ∈ 𝑈 ∀𝑌 ∈ 𝑈 (𝑋 ∖ 𝑌 = 𝑌′ ∖ 𝑋′) [Marks:][GATE: 2015][SET-3]
Q115. Let # be a binary operator defined as X # Y = X′ + Y′; where X and Y are
Boolean variables.
Consider the following two statements:
S1: (P # Q) # R = P # (Q # R)
S2: Q # R = R # Q
Which of the following is/are true for the Boolean variables P, Q and R?
(a) Only S1 is True
(b) Only S2 is True
(c) Both S1 and S2 are True
(d) Neither S1 nor S2 are True [Marks:][GATE: 2015][SET-3]
Q116. Consider a binary tree T that has 200 leaf nodes. Then, the number of nodes in
T that have exactly two children are _________.[GATE: 2015][SET-3]
Q117. 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"
Which of the following options is correct?
(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 [GATE: 2015][SET-3]
Q118. Let G be connected undirected graph of 100 vertices and 300 edges. The weight
of a minimum spanning tree of G is 500. When the weight of each edge of G is
increased by five, the weight of a minimum spanning tree becomes ________
[Marks:][GATE: 2015][SET-3]
Q119. Let R be a relation on the set of ordered pairs of positive integers such that
((p, q), (r, s)) ∈ R if and only if p–s = q–r.
Which one of the following is true about R?
(a) Both reflexive and symmetric
(b) Reflexive but not symmetric
(c) Not reflexive but symmetric
(d) Neither reflexive nor symmetric
[Marks:][GATE: 2015][SET-3]
Q120. The number of 4 digit numbers having their digits in non-decreasing order (from
left to right) constructed by using the digits belonging to the set {1, 2, 3} is _____
.
[Marks:][GATE: 2015][SET-3]
Q121. 1 −1 2
In the given matrix [0 1 0], one of the eigenvalues is 1. The eigenvector
1 2 1
corresponding to the eigenvalues 1 are
(a){α(4, 2, 1) | α ≠ 0, α ∈ R}
(b){α(-4, 2, 1) | α ≠ 0, α ∈ R}
(c){α(2, 0, 1) | α ≠ 0, α ∈ R}
(d){α(-2, 0, 1) | α ≠ 0, α ∈ R}
[Marks:][GATE: 2015][SET-3]
Q122.
[Marks:][GATE: 2015][SET-3]
Q124.
Q125. Let G be a weighted connected undirected graph with distinct positive edge
weights. If every edge weight is increased by the same value, then which of the
following statements is/are TRUE?
P: Minimum spanning tree of G does not change.
Q: Shortest path between any pair of vertices does not change.
(a) P only
(b) Q only
(c) Neither P nor Q
(d) Both P and Q
[Marks: 2][GATE: 2016][SET-1]
Q126. A function f : N+→N+ , defined on the set of positive integers N+, satisfies the
following properties:
f(n)=f(n/2) if n is even
f(n)=f(n+5) if n is odd
Let R={i∣∃j:f(j)=i} be the set of distinct values that f takes. The maximum possible
size of R is ___________. [Marks: 2][GATE: 2016][SET-1]
Q127. Consider the weighted undirected graph with 4 vertices, where the weight of
edge {i,j} is.
given by the entry Wij in the matrix W
The largest possible integer value of x, for which at least one shortest path
between some pair of vertices will contain the edge with weight x is ___________.
Q128. Let G be a complete undirected graph on 4 vertices, having 6 edges with weights
being 1,2,3,4,5, and 6. The maximum possible weight that a minimum weight
spanning tree of G can have is __________
[Marks: 1][GATE: 2016][SET-1]
Q129. G = (V, E) is an undirected simple graph in which each edge has a distinct weight,
and e is a particular edge of G. Which of the following statements about the
minimum spanning trees (MSTs) of G is/are TRUE?
Q132.
Q133. A probability density function on the interval [a,1] is given by 1/x 2 and outside
this interval the value of the function is zero. The value of a is _________..
[Marks: ][GATE: 2016][SET-1]
Q134. Two eigenvalues of a 3 × 3 real matrix P are (2 + √-1) and 3. The determinant of
P is __________
[Marks: ][GATE: 2016][SET-1]
[Marks:2][GATE: 2016][SET-]
[Marks:2][GATE: 2016][SET-]
Q137. Consider the following experiment.
Step2. If the outcomes are (TAILS, HEADS) then output Y and stop.
Step3. If the outcomes are either (HEADS, HEADS) or (HEADS, TAILS), then
output N and stop.
The probability that the output of the experiment is Y is (up to two decimal places)
_____
[Marks:2][GATE: 2016][SET-]
i. false
ii. QQ
iii. true
iv. P∨Q
v. ¬Q∨P
The number of expressions given above that are logically implied by P∧(P⇒Q) is
___________.
[Marks:1][GATE: 2016][SET-2]
Q139. The minimum number of colours that is sufficient to vertex-colour any planar
graph is ________.
[Marks:1][GATE: 2016][SET-2]
Q140. A binary relation R on N×N is defined as follows: (a,b)R(c,d) if a≤c or b≤d.
Consider the following propositions:
P: R is reflexive.
Q: R is transitive.
[Marks:2][GATE: 2016][SET-2]
Q141. Which one of the following well-formed formulae in predicate calculus
is NOT valid ?
[Marks:2][GATE: 2016][SET-2]
[Marks:2][GATE: 2016][SET-2]
Q143. Let f(x) be a polynomial and g(x) = f'(x) be its derivative. If the degree of (f(x) + f(-
x)) is 10, then the degree of (g(x) - g(-x)) is __________.
[Marks:2][GATE: 2016][SET-2]
Q146. Suppose that the eigenvalues of matrix A are 1, 2, 4. The determinant of (A-1)T is
_________
[Marks:2][GATE: 2016][SET-2]
Q147. The value of the expression 1399(mod 17), in the range 0 to 16, is ________.
[Marks:2][GATE: 2016][SET-2]
F: ∀ x (∃ y R(x,y)).
Assuming non-empty logical domains, which of the sentences below are implied
by F?
Q150. Let G = (V, E) be any connected undirected edge-weighted graph. The weights of
the edges in E are positive any distinct. Consider the following statements:
Q151. Let p, q, and r be the propositions and the expression (p -> q) -> r be a
contradiction. Then, the expression (r -> p)-> q is
(a) a tautology
(b) a contradiction
(c) always TRUE when p is FALSE
(d) always TRUE when q is TRUE
[Marks: 2][GATE: 2017][SET-1]
Q152. The number of integers between 1 and 500 (both inclusive) that are divisible by
3 or 5 or 7 is ______.
Q154. Let X be a Gaussian random variable with mean 0 and variance σ2. Let Y =
max(X, 0) where max(a, b) is the maximum of a and b. The median of Y is
__________.
(a)0 (b)1 (c)2 (d)3
[Marks: ][GATE: 2017][SET-1]
Q155.
𝑥 7 −2𝑥 5 +1
The value oflim
𝑋→1 𝑥 3 −3𝑥 2 +2
Q158. Let A be m×n real valued square symmetric matrix of rank 2 with expression
given below.
𝑛 𝑛
2
∑∑𝐴
𝑖𝑗
𝑖=𝑗 𝑗=1
Q159.The number of integers between 1 and 500 (both inclusive) that are divisible by
3 or 5 or 7 is _____.
(a)271
(b)272
(c)273
(d)274
Q160. Let p, q, r denote the statement “It is raining”, “It is cold”, and “It is pleasant”,
respectively. Then the statement “It is not raining and it is pleasant, and it is
not pleasant only if it is raining and it is cold” is represented by:
(A) (¬ p ∧ r) ∧ ((¬ r → (p ∧ q))
(B) (¬ p ∧ r) ∧ ((p ∧ q) → ¬ r)
(C) (¬ p ∧ r) ∨ ((p ∧ q) → ¬ r)
(D) (¬ p ∧ r) ∨ ((r → (p ∧ q))
[Marks: 1][GATE: 2017][SET-2]
Q161. Consider the set X={a,b,c,d,e} under partial ordering
R={(a,a),(a,b),(a,c),(a,d),(a,e),(b,b),(b,c),(b,e),(c,c),(c,e),(d,d),(d,e),(e,e)}
The Hasse diagram of the partial order (X,R) is shown below.
The minimum number of ordered pairs that need to be added to R to make (X,R)
a lattice is ______
are , respectively
2 16 2
(a) and (b) and 0
𝜋 𝜋 𝜋
4 4 16
(c) and 0 (d) and
𝜋 𝜋 𝜋
4 5 7 11
(a) (b) (c) (d)
5 6 8 12
Q167. If a random variable X has a Poisson distribution with mean 5, then the
expectation E[(X + 2)2] equals _________.
[Marks:1][GATE: 2018]
Q171. Let G be a finite group on 84 elements. The size of a largest possible proper
subgroup of G is ________. [Marks: 1][GATE: 2018]
Q172. L et G be a simple undirected graph. Let TD be a depth first search tree of G.
Let TB be a breadth first search tree of G. Consider the following statements.
(I) No edge of G is a cross edge with respect to TD. (A cross edge in G is between
two
Nodes neither of which is an ancestor of the other in TD.)
(II) For every edge (u, v) of G, if u is at depth i and v is at depth j in TB, then
|𝑖−𝑗| = 1.
Which of the statements above must necessarily be true?
(a) I only (b) II only
(c) Both I and II (d) Neither I nor II
[Marks: 2][GATE: 2018]
Q173. Consider the first-order logic sentence
𝜑 ≡ ∃𝑠∃𝑡∃𝑢∀𝑣∀𝑤∀𝑥∀𝑦 𝜓(𝑠, 𝑡, 𝑢, 𝑣, 𝑤, 𝑥, 𝑦)
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 of size greater than 7.
(d) Every model of φ has a universe of size equal to 7
[Marks: 2][GATE: 2018]
Q174. Let G be a graph with 100! Vertices, with each vertex labelled by a distinct
permutation of the numbers 1, 2, … , 100. There is an edge between vertices 𝑢
and 𝑣 if and only if the label of 𝑢 can be obtained by swapping two adjacent
numbers in the label of 𝑣. Let 𝑦 denote the degree of a vertex in G, and 𝑧 denote
the number of connected components in G. Then, 𝑦 + 10𝑧 = _____.
[Marks: 2][GATE: 2018]
Choose a value for x that will maximize the number of minimum weight
spanning trees (MWSTs) of G. The number of MWSTs of G for this value of x is
______. [Marks: ][GATE: 2018]
Q176. Consider a matrix A = uv T where u =(1), v =(1). Note that vT denotes the
2 2
transpose of V. The largest eigenvalue of A is __________________
[Mark: 1][GATE: 2018]
Q177. Two people, P and Q, decide to independently roll two identical dice, each with
6 faces, numbered 1 to 6. The person with the lower number wins. In case of a
tie, they roll the dice repeatedly until there is no tie. Define a trial as a throw
of the dice by P and Q. Assume that all 6 numbers on each dice are equi-
probable and that all trials are independent. The probability (rounded to 3
decimal places) that one of them wins on the third trial is __________
[Marks: ][GATE: 2018]
Q178. Which one of the following is a closed form expression for the generating
function of the sequence {a n}, where an = 2n+3 for all n = 0, 1, 2, …?
(a)3/(1-x)2 (b)3x/(1-x)2 (c)2-x/(1-x)2 (d)3-x/(1-x)2
[Marks: ][GATE: 2018]
Q179. The value of ∫𝜋/4 𝑥 cos(𝑥 2 ) dx correct to three decimal places is
0
Q180. Consider Guwahati (G) and Delhi (D) whose temperatures can be classified as
high (H), medium (M) and low (L). Let P(HG) denote the probability that Guwahati
has high temperature. Similarly, P(MG) and P(LG) denotes the probability of
Guwahati having medium and low temperatures respectively. Similarly, we use
P(HD), P(MD) and P(LD) for Delhi.
The following table gives the conditional probabilities for Delhi’s temperature
given Guwahati’s temperature
Consider the first row in the table above. The first entry denotes that if Guwahati
has high temperature (HG) then the probability of Delhi also having a high
temperature (HD) is 0.40; i.e., P(HD∣ HG) = 0.40. Similarly, the next two entries are
P(MD∣ HG) = 0.48 and P(LD∣ HG) = 0.12. Similarly for the other rows.
If it is known that P(HG) = 0.2, P(MG) = 0.5, and P(LG) = 0.3, then the probability
(correct to two decimal places) that Guwahati has high temperature given that
Delhi has high temperature is ______ [Marks: ][GATE: 2018]
Q181. Let N be the set of natural numbers. Consider the following sets,
P: Set of Rational numbers (positive and negative)
Q: Set of functions from {0, 1} to N
R: Set of functions from N to {0, 1}
S: Set of finite subsets of N
Which of the above sets are countable?
(a)Q and S only (b)P and S only
(c)P and R only (d)P, Q and S only
[Marks: ][GATE: 2018]
Q182. Consider a matrix P whose only eigenvectors are the multiples of [1].
4
Consider the following statements.
(I) P does not have an inverse
(II) P has a repeated eigenvalue
(III) P cannot be diagonalized
Which one of the following options is correct?
(a)Only I and III are necessarily true
(b)Only II is necessarily true
(c)Only I and II are necessarily true
(d)Only II and III are necessarily true [Marks: ][GATE: 2018]
Q183. Let U = {1,2,...,n}. Let A = {(x,X)|x ∈ X, X ⊆ U}. Consider the following two
statements on |A|.
(I) |A|=n. 2n-1
𝑛
(II) |A| =∑𝑛𝑘=1 𝑘. ( )
𝑘
Which of the above statements is/are TRUE?
(a) Only I (b) Only II
(c) Both I and II (d) Neither I nor II
[Marks: 1][GATE:2019]
Q184. Let G be an arbitrary group. Consider the following relations on G:
R1: ∀a b∈ G, aR1 b if and only if ∃g ∈ G such that a = g–1bg
R2: ∀a b∈ G, aR1 b if and only if a = b–1
Which of the above is/are equivalence relation/relations?
(a) R1 and R2 (b) R1 only
(c) R2 only (d) Neither R1 nor R2
[Marks: 1][GATE:2019]
Q185.
Let G be an undirected complete graph, on n vertices, where n > 2. Then, the
number of different Hamiltonian cycles in G is equal to
(a) n ! (b) (n – 1)! (c) 1 (d) ( 1)(n-1)!/2
[Marks:2][GATE:2019]
Q186. Consider the first order predicate formula ϕ :
∀x[(∀z z⏐x ⇒ ((z = x) ∨ (z = 1))) ⇒∃w (w > x) ∧ (∀z z⏐w ⇒ ((w = z) ∨ (z = 1)))]
Here ‘a⏐b’ denotes that ‘a divides b’, where a and b are integers. Consider the
following sets:
S1 : {1, 2, 3, ..., 100}
S2: Set of all positive integers
S3: Set of all integers
Which of the above sets satisfy ϕ?
(a) S1and S3 (b) S2and S3
(c) S2and S3 (d) S1, S2 and S3
[Marks:2][GATE:2019]
Q187. Let G be any connected, weighted, undirected graph:
I. G has a unique minimum spanning tree, if no two edges of G have the same
weight.
II. G has a unique minimum spanning tree, if for every cut G, there is a unique
minimum
weight edge crossing the cut.
Which of the above two statements is/are TRUE?
(a) Neither I nor II (b) I only
(c) II only (d) Both I and II
[Marks:2][GATE:2019]
Q188. Compute lim 𝑥 4 −81
𝑥→3 2𝑥 2 −5𝑥−3
Q190. Suppose Y is distributed uniformly in the open interval (1, 6). The probability
that the polynomial 3x2 + 6xY + 3Y + 6 has only real roots is (rounded off to 1
decimal place) _________.
(a)0.3 (b)0.9 (c)0.1 (d)0.8
[Marks: ][GATE:2019]
Q192. Let G be a group of 35 elements. Then the largest possible size of a subgroup of
G other than G itself is ______. [Marks: 1][GATE:2020]
Q193. Let R be the set of all binary relations on the set {1,2,3}. Suppose a relation is
chosen from R at random. The probability that the chosen relation is reflexive
(round off to 3 decimal places) is _____. [Marks:1][GATE:2020]
1. B 2. A 3. A 4. D 5. B
6. C 7. D 8. B 9. D 10. B
11. C 12. C 13. A 14. D 15. B
16. D 17. B 18. A 19. A 20. D
21. B 22. A 23. B 24. C 25. C
26. A 27. D 28. D 29. C 30. B
31. C 32. D 33. B 34. D 35. C
36. 45 37. D 38. B 39. D 40. C
41. B 42. A 43. C 44. A 45. D
46. D 47. C 48. A 49. A 50. D
51. C 52. 89 53. 16 54. C 55. B
56. B 57. 0 58. C 59. (-2) 60. A
61. 10 62. A 63. A 64. 5 65. 6
66. B 67. A 68. A 69. A 70. A
71. A 72. 6 73. A 74. 8 75. D
76. D 77. 5 78. B 79. 4 80. C
81. A 82. A 83. D 84. A 85. 2
86. 4 87. A 88. A 89. B 90. A
91. C 92. C 93. A 94. D 95. 24
96. 69 97. 2048 98. 5 99. D 100. D
101. A 102. A 103. D 104. 36 105. 0.95
106. D 107. B 108. C 109. A 110. 36
111. A 112. C 113. C 114. D 115. B
116. 199 117. A 118. 995 119. C 120. 15
121. B 122. A 123. C 124. 6 125. A
126. 2 127. 12 128. 7 129. B 130. 11
131. B 132. 1 133. 0.5 134. 15 135. 198
136. 10 137. 0.33 138. 4 139. 4 140. B
141. D 142. B 143. 9 144. C
145. 0.55 146. 0.125 147. 4 148. D 149. B
150. A 151. D 152. 271 153. C 154. 0
155. C 156. D 157. A 158. B 159. 271
160. A 161. 0 162. 16 163. C 164. B
165. A 166. A 167. 54 168. 15 169. 5
170. 3 171. 42 172. A 173. A 174. 109
175. 4 176. 3 177. 0.023 178. D 179. A
180. 0.60 181. D 182. D 183. C 184. B
185. D 186. C 187. D 188. D 189. C
190. D 191. A 192. 7 193. 0.125 194. B
195. 0.5 196. 7 197. C 198. 12 199. C