GATE CS question library
Practise GATE CS Computer Science previous year questions free. Browse by subject, syllabus topic, year and question type, with answers and available solutions.
Subject, topic, year and type filter the full library. Match any choice within a filter, and all selected filter categories. Search, source and sort apply to this page.
20 on this page
The atomic fetch-and-set instruction unconditionally sets the memory location to and fetches the old value of in without allowing any intervening access to the memory location . Consider the following implementation of and functions on a binary semaphore . void P (binary_semaphore *s) { unsigned y; …
Consider the following C code segment. for (i = 0, i < n; i++) { for (j = 0; j < n; j++) { if (i%2) { x += (4*j + 5*i); y += (7 + 4*j); } } } Which one of the following is false?
Consider the following translation scheme. Here is a token that represents an integer and …
Consider these two functions and two statements S1 and S2 about them. int work1(int *a, int i, int j) { int x = a[i+2]; a[j] = x+1; return a[i+2] - 3; } int work2(int *a, int i, int j) { int t1 = i+2; int t2 = a[t1]; a[j] = t2+1; return t2 - 3; } S1: The transformation form work1 to work2 is valid, i.e., for any program state and input arguments, work2 will …
Consider the following code written in a pass-by-reference language like FORTRAN and these statements about the code. subroutine swap(ix,iy) it = ix L1 : ix = iy L2 : iy = it end ia = 3 ib = 8 call swap (ia, ib+5) print *, ia, ib end S1: The compiler will generate code to allocate a temporary nameless cell, initialize it to 13, and pass the address of the …
Consider this C code to swap two integers and these five statements: the code void swap (int *px, int *py) { *px = *px - *py; *py = *px + *py; *px = *py - *px; } S1: will generate a compilation error S2: may generate a segmentation fault at runtime depending on the arguments passed S3: correctly implements the swap procedure for all input pointers referring …
Given two arrays of numbers and where each number is or , the fastest algorithm to find the largest span such that or report that there is not such span,
Consider the following C-function in which and are two sorted integer arrays and be another integer array, void xyz(int a[], int b [], int c []){ int i,j,k; i=j=k=0; while ((i<n) && (j<m)) if (a[i] < b[j]) c[k++] = a[i++]; else c[k++] = b[j++]; } Which of the following condition(s) hold(s) after the termination …
The median of elements can be found in time. Which one of the following is correct about the complexity of quick sort, in which median is selected as pivot?
Consider the following recurrence: Which one of the following is true?
A set can be represented by an array as follows: Consider the following algorithm in which , , and are Boolean arrays of size : algorithm zzz(x[], y[], z[]) { int i; for(i=0; i<n; ++i) z[i] = (x[i] ∧ ~y[i]) ∨ (~x[i] …
An implementation of a queue , using two stacks and , is given below: void insert (Q, x) { push (S1, x); } void delete (Q) { if (stack-empty(S2)) then if (stack-empty(S1)) then { print(“Q is empty”); return; } else while (!(stack-empty(S1))){ x=pop(S1); push(S2,x); } x=pop(S2); } Let insert and delete operations be …
Let be a depth first search tree in an undirected graph . Vertices and are leaves of this tree . The degrees of both and in are at least . which one of the following statements is true?
Consider the following graph: Which one of the following cannot be the sequence of edges added, in that order, to a minimum spanning tree using Kruskal’s algorithm?
Station needs to send a message consisting of packets to Station using a sliding window (window size ) and go-back- error control strategy. All packets are ready and immediately available for transmission. If every th packet that transmits gets lost (but no acks from ever get lost), then what is the number of …
Station uses packets to transmit messages to Station using a sliding window protocol. The round trip delay between A and is and the bottleneck bandwidth on the path between and is . What is the optimal window size that should use?
Two computers and are configured as follows. has IP address and netmask . has IP address and netmask . Which one of the following statements is true?
Consider a new instruction named branch-on-bit-set (mnemonic bbs). The instruction “bbs reg, pos, label” jumps to label if bit in position pos of register operand reg is one. A register is -bits wide and the bits are numbered to bit in position being the least significant. Consider the following emulation of this instruction on a …
A CPU has a five-stage pipeline and runs at GHz frequency. Instruction fetch happens in the first stage of the pipeline. A conditional branch instruction computes the target address and evaluates the condition in the third stage of the pipeline. The processor stops fetching new instructions following a conditional branch until the branch outcome is …
A CPU has a cache with block size bytes. The main memory has banks, each bank being bytes wide. Consecutive − byte chunks are mapped on consecutive banks with wrap-around. All the banks can be accessed in parallel, but two accesses to the same bank must be serialized. A cache block access may involve multiple iterations of …
