# Category Archives: Algorithms Quiz

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)… Read More
The length of the path from v5 to v6 in the MST of previous question with n = 10 is (A) 11 (B) 25 (C)… Read More
An undirected graph G(V, E) contains n ( n > 2 ) nodes named v1 , v2 ,….vn. Two nodes vi , vj are connected… Read More
Suppose we are sorting an array of eight integers using heapsort, and we have just finished some heapify (either maxheapify or minheapify) operations. The array… Read More
Suppose we are sorting an array of eight integers using quicksort, and we have just finished the first partitioning with the array looking like this:… Read More
Traversal of a graph is different from tree because (A) There can be a loop in graph so we must maintain a visited flag for… Read More
We use dynamic programming approach when (A) We need an optimal solution (B) The solution has optimal substructure (C) The given problem can be reduced… Read More
Which of the following is not O(n^2)? (A) (15^10) * n + 12099 (B) n^1.98 (C) n^3 / (sqrt(n)) (D) (2^20) * n Answer: (C)… Read More
Which of the following algorithms can be used to most efficiently determine the presence of a cycle in a given graph ? (A) Depth First… Read More
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… Read More
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… Read More
Which of the following standard algorithms is not a Greedy algorithm? (A) Dijkstra’s shortest path algorithm (B) Prim’s algorithm (C) Kruskal algorithm (D) Huffman Coding… Read More
The recurrence relation capturing the optimal time of the Tower of Hanoi problem with n discs is. (GATE CS 2012) (A) T(n) = 2T(n –… Read More
What is the time complexity of fun()? int fun(int n) {   int count = 0;   for (int i = 0; i < n; i++)      for… Read More
What is the worst case time complexity of following implementation of subset sum problem. // Returns true if there is a subset of set[] with… Read More