Algorithms questions

Q20

GATE CS 2019 CSAlgorithm DesignNAT1 mark
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 __________.
Show answer without attempting

Answer: 0.08

Q25

GATE CS 2019 CSAlgorithm DesignNAT1 mark
Consider a sequence of 14 elements: A=[−5,−10,6,3,−1,−2,13,4,−9,−1,4,12,−3,0]A = [-5, -10, 6, 3, -1, -2, 13, 4, -9, -1, 4, 12, -3, 0].
The subsequence sum S(i,j)=∑k=ijA[k]S(i, j) = \sum_{k=i}^j A[k]. Determine the maximum of S(i,j)S(i, j), where 0≤i≤j<140 \le i \le j < 14. (Divide and conquer approach may be used.)

Answer: __________.
Show answer without attempting

Answer: 29

Q37

GATE CS 2019 CSSearching Sorting and HashingMCQ2 marks−2/3 if wrong
There are nn unsorted arrays: A1,A2,...,AnA_1, A_2, ..., A_n. Assume that nn is odd. Each of A1,A2,...,AnA_1, A_2, ..., A_n contains nn 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,...,AnA_1, A_2, ..., A_n is
Show answer without attempting

Answer: C

Q38

GATE CS 2019 CSGraph AlgorithmsMCQ2 marks−2/3 if wrong
Let GG be any connected, weighted, undirected graph.

I. GG has a unique minimum spanning tree, if no two edges of GG have the same weight.
II. GG has a unique minimum spanning tree, if, for every cut of GG, there is a unique minimum-weight edge crossing the cut.

Which of the above two statements is/are TRUE?
Show answer without attempting

Answer: C

0/40 correct0 marks

Related topics in GATE CS