Algorithms questions — page 5 of 7

Q13

GATE CS 2016 CS-2Searching Sorting and HashingMCQ1 mark−1/3 if wrong
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)\Theta(n^2) time
II. Bubblesort runs in Θ(n2)\Theta(n^2) time
III. Mergesort runs in Θ(n)\Theta(n) time
IV. Insertion sort runs in Θ(n)\Theta(n) time
Show answer without attempting

Answer: D

Q14

GATE CS 2016 CS-2Graph AlgorithmsMCQ1 mark−1/3 if wrong
The Floyd-Warshall algorithm for all-pair shortest paths computation is based on
Show answer without attempting

Answer: C

Q38

GATE CS 2016 CS-2Algorithm DesignNAT2 marks
Let A1,A2,A3A_1, A_2, A_3, and A4A_4 be four matrices of dimensions 10×510 \times 5, 5×205 \times 20, 20×1020 \times 10, and 10×510 \times 5, respectively. The minimum number of scalar multiplications required to find the product A1A2A3A4A_1 A_2 A_3 A_4 using the basic matrix multiplication method is _________.
Show answer without attempting

Answer: 1500.0

Q41

GATE CS 2016 CS-2Graph AlgorithmsMCQ2 marks−2/3 if wrong
In an adjacency list representation of an undirected simple graph G=(V,E)G = (V,E), each edge (u,v)(u, v) has two adjacency list entries: [v][v] in the adjacency list of uu, and [u][u] in the adjacency list of vv. These are called twins of each other. A twin pointer is a pointer from an adjacency list entry to its twin. If ∣E∣=m|E| = m and ∣V∣=n|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?
Show answer without attempting

Answer: B

Q20

GATE CS 2015 CS-3Algorithm AnalysisMCQ1 mark−1/3 if wrong
Consider the equality ∑i=0ni3=X\sum_{i=0}^{n} i^3 = X and the following choices for XX

I.Θ(n4)II.Θ(n5)III.O(n5)IV.Ω(n3)\begin{array}{rl} \text{I.} & \Theta(n^4) \\ \text{II.} & \Theta(n^5) \\ \text{III.} & O(n^5) \\ \text{IV.} & \Omega(n^3) \end{array}

The equality above remains correct if XX is replaced by
Show answer without attempting

Answer: C

Q22

GATE CS 2015 CS-3Searching Sorting and HashingNAT1 mark
Given a hash table TT with 25 slots that stores 2000 elements, the load factor α\alpha for TT is ____________.
Show answer without attempting

Answer: 80

Q37

GATE CS 2015 CS-3Algorithm AnalysisMCQ2 marks−2/3 if wrong
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?
Show answer without attempting

Answer: B

Q55

GATE CS 2015 CS-3Graph AlgorithmsNAT2 marks
Let GG be a connected undirected graph of 100 vertices and 300 edges. The weight of a minimum spanning tree of GG is 500. When the weight of each edge of GG is increased by five, the weight of a minimum spanning tree becomes ____________.
Show answer without attempting

Answer: 995

Q64

GATE CS 2015 CS-3Algorithm AnalysisMCQ2 marks−2/3 if wrong
Let f(n)=nf(n) = n and g(n)=n(1+sin⁡n)g(n) = n^{(1+\sin n)}, where nn is a positive integer. Which of the following statements is/are correct?

I.f(n)=O(g(n))II.f(n)=Ω(g(n))\begin{array}{rl} \text{I.} & f(n) = O(g(n)) \\ \text{II.} & f(n) = \Omega(g(n)) \end{array}
Show answer without attempting

Answer: D

Q13

GATE CS 2015 CS-1Algorithm DesignMCQ1 mark−1/3 if wrong
Match the following:

(P) Prim's algorithm for minimum spanning tree
(Q) Floyd-Warshall algorithm for all pairs shortest paths
(R) Mergesort
(S) Hamiltonian circuit

(i) Backtracking
(ii) Greedy method
(iii) Dynamic programming
(iv) Divide and conquer
Show answer without attempting

Answer: C

Q14

GATE CS 2015 CS-1Algorithm AnalysisMCQ1 mark−1/3 if wrong
Which one of the following is the recurrence equation for the worst case time complexity of the Quicksort algorithm for sorting nn (≥2\geq 2) numbers? In the recurrence equations given in the options below, cc is a constant.
Show answer without attempting

Answer: B

Q51

GATE CS 2015 CS-1Graph AlgorithmsMCQ2 marks−2/3 if wrong
Let G=(V,E)G = (V, E) be a simple undirected graph, and ss be a particular vertex in it called the source. For x∈Vx \in V, let d(x)d(x) denote the shortest distance in GG from ss to xx. A breadth first search (BFS) is performed starting at ss. Let TT be the resultant BFS tree. If (u,v)(u, v) is an edge of GG that is not in TT, then which one of the following CANNOT be the value of d(u)−d(v)d(u) - d(v)?
Show answer without attempting

Answer: D

Q60

GATE CS 2015 CS-1Algorithm AnalysisMCQ2 marks−2/3 if wrong
An algorithm performs (log⁡N)1/2(\log N)^{1/2} find operations, NN insert operations, (log⁡N)1/2(\log N)^{1/2} delete operations, and (log⁡N)1/2(\log N)^{1/2} decrease-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?
Show answer without attempting

Answer: A

Q63

GATE CS 2015 CS-1Graph AlgorithmsNAT2 marks
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 ________.
Question figure
Show answer without attempting

Answer: 69

Q64

GATE CS 2015 CS-1Algorithm AnalysisMCQ2 marks−2/3 if wrong
Consider the following C function.
int fun1(int n) {
    int i, j, k, p, q = 0;
    for (i = 1; i < n; ++i) {
        p = 0;
        for (j = n; j > 1; j = j/2)
            ++p;
        for (k = 1; k < p; k = k*2)
            ++q;
    }
    return q;
}
Which one of the following most closely approximates the return value of the function fun1?
Show answer without attempting

Answer: D

Q16

GATE CS 2015 CS-2Algorithm AnalysisMCQ1 mark−1/3 if wrong
An unordered list contains nn distinct elements. The number of comparisons to find an element in this list that is neither maximum nor minimum is
Show answer without attempting

Answer: D

Q47

GATE CS 2015 CS-2Algorithm DesignMCQ2 marks−2/3 if wrong
Given below are some algorithms, and some algorithm design paradigms.

1. Dijkstra's Shortest Path
2. Floyd-Warshall algorithm to compute all pairs shortest path
3. Binary search on a sorted array
4. Backtracking search on a graph

i. Divide and Conquer
ii. Dynamic Programming
iii. Greedy design
iv. Depth-first search
v. Breadth-first search

Match the above algorithms on the left to the corresponding design paradigm they follow.
Show answer without attempting

Answer: C

Q49

GATE CS 2015 CS-2Algorithm DesignMCQ2 marks−2/3 if wrong
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 kthk^{th} smallest element in an array a[] of size n using the partition function. We assume k≤nk \le n.
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
Show answer without attempting

Answer: A

Q50

GATE CS 2015 CS-2Searching Sorting and HashingMCQ2 marks−2/3 if wrong
Which one of the following hash functions on integers will distribute keys most uniformly over 10 buckets numbered 0 to 9 for ii ranging from 0 to 2020?
Show answer without attempting

Answer: B

Q13

GATE CS 2014 CS-2Algorithm AnalysisMCQ1 mark−1/3 if wrong
Which one of the following correctly determines the solution of the recurrence relation with T(1)=1T(1) = 1?

T(n)=2T(n2)+log⁡nT(n) = 2T\left(\frac{n}{2}\right) + \log n
Show answer without attempting

Answer: A

0/200 correct0 marks

Related topics in GATE CS