Algorithms GATE CS PYQ Quiz (original) (raw)
The worst case running time to search for an element in a balanced in a binary search tree with n2^n elements is
(A) [Tex]\Theta(n log n)[/Tex]
(B) [Tex]\Theta (n2^n) [/Tex]
(C) [Tex]\Theta (n) [/Tex]
(D) [Tex]\Theta (log n) [/Tex]
The recurrence relation capturing the optimal execution time of the Towers of Hanoi problem with n discs is
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)
[Tex]A(n) = \\Omega(W(n))[/Tex]
(B)
[Tex]A(n) = \\Theta(W(n))[/Tex]
(C)
[Tex]A(n) = O(W(n))[/Tex]
(D)
[Tex]A(n) = o(W(n))[/Tex]
Let G be a weighted graph with edge weights greater than one and G'be the graph constructed by squaring the weights of edges in G. Let T and T' be the minimum spanning trees of G and G', respectively, with total weights t and t'. Which of the following statements is TRUE?
- T' = T with total weight t' = t2
- T' = T with total weight t' < t2
- T' != T but total weight t' = t2
A list of n strings, each of length n, is sorted into lexicographic order using the merge-sort algorithm. The worst case running time of this computation is
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.

Which one of the following statements is TRUE for all positive functions _f (_n)?
- [Tex]f(n^{2}) = \theta (f(n^{2})) [/Tex], when _f (_n) is a polynomial
- [Tex]f(n^{2}) = o (f(n^{2}))[/Tex]
- [Tex]f(n^{2}) = O(f(n^{2})) [/Tex], when f (n) is an exponential function
- [Tex]f(n^{2}) = Ω(f(n^{2}))[/Tex]
Which one of the following is the recurrence equation for the worst case time complexity of the Quicksort algorithm for sorting n(≥ 2) numbers? In the recurrence equations given in the options below, c is a constant.
- T(n) = T(n – 1) + T(0) + cn
Randomized quicksort is an extension of quicksort where the pivot is chosen randomly. What is the worst case complexity of sorting n numbers using randomized quicksort?
In a permutation a1.....an of n distinct integers, an inversion is a pair (ai, aj) such that i < j and ai > aj. What would be the worst-case time complexity of the Insertion Sort algorithm, if the inputs are restricted to permutations of 1.....n with at most n inversions?
There are 198 questions to complete.
Take a part in the ongoing discussion