Top 50 Algorithms MCQs with Answers The word Algorithm means “A set of rules to be followed in calculations or other problem-solving operations” Or “A procedure for solving a mathematical problem in a finite number of steps… More on Algorithms… Top 50 Algorithms MCQs with Answers Please wait while the activity loads. If this activity does not load, try refreshing your browser. Also, this page requires javascript. Please visit using a browser with javascript enabled. If loading fails, click here to try again Question 1 Which of the following standard algorithms is not Dynamic Programming based? Bellman–Ford Algorithm for single source shortest path Floyd Warshall Algorithm for all pairs shortest paths 0-1 Knapsack problem Prim\'s Minimum Spanning Tree Top MCQs on Dynamic Programming with Answers Top 50 Algorithms MCQs with Answers Discuss itQuestion 1-Explanation: Prim\'s Minimum Spanning Tree is a Greedy Algorithm. All others are dynamic programming based. Hence (D) is the correct answer. Question 2 Which of the following is not true about comparison-based sorting algorithms? The minimum possible time complexity of a comparison-based sorting algorithm is O(n(log(n)) for a random input array Any comparison based sorting algorithm can be made stable by using position as a criteria when two elements are compared Counting Sort is not a comparison based sorting algorithm Heap Sort is not a comparison based sorting algorithm. Top MCQs on Sorting Algorithms with Answers Top MCQs on Complexity Analysis of Algorithms with Answers Top MCQs on CountingSort Algorithm with Answers Top MCQs on HeapSort Algorithm with Answers Top 50 Algorithms MCQs with Answers Discuss itQuestion 2-Explanation: Heap Sort is not a comparison based sorting algorithm is not correct. Question 3 Which of the following is not O(n2)? (15) * n2 n1.98 n3/(sqrt(n)) (20) * n2 Top MCQs on Complexity Analysis of Algorithms with Answers Top 50 Algorithms MCQs with Answers Discuss itQuestion 3-Explanation: The order of growth of option c is n2.5 which is higher than n2. Question 4Consider the following C program int main() { int x, y, m, n; scanf ("%d %d", &x, &y); /* x > 0 and y > 0 */ m = x; n = y; while (m != n) { if(m>n) m = m - n; else n = n - m; } printf("%d", n); } What does the program compute? (GATE CS 2004)x + y using repeated subtractionx mod y using repeated subtractionthe greatest common divisor of x and ythe least common multiple of x and y Top MCQs on Divide and Conquer Algrithm with Answers Top 50 Algorithms MCQs with Answers Discuss itQuestion 4-Explanation: This is an implementation of Euclid’s algorithm to find GCDQuestion 5Which of the following is not a backtracking algorithm?Knight tour problem N queen problem Tower of hanoi M coloring problem Top MCQs on Backtracking Algorithm with Answers Top 50 Algorithms MCQs with Answers Discuss itQuestion 5-Explanation: Knight tour problem, N Queen problem and M coloring problem involve backtracking. Tower of hanoi uses simple recursion.Question 6Suppose T(n) = 2T(n/2) + n, T(0) = T(1) = 1 Which one of the following is false. ( GATE CS 2005) a) T(n) = O(n^2) b) T(n) = (nLogn) c) T(n) = (n^2) d) T(n) = O(nLogn) ABCDTop MCQs on Complexity Analysis using Recurrence Relations with Answers Top 50 Algorithms MCQs with Answers Discuss itQuestion 6-Explanation: See question 4 of http://www.geeksforgeeks.org/data-structures-and-algorithms-set-23/ for explanation.Question 7 In a complete k-ary tree, every internal node has exactly k children. The number of leaves in such a tree with n internal nodes is: nk (n – 1) k+ 1 n( k – 1) + 1 n( k – 1) Top MCQs on Algorithms in DSA with Answers Top 50 Algorithms MCQs with Answers Discuss itQuestion 7-Explanation: For an k-ary tree where each node has k children or no children, following relation holds L = (k-1)*n + 1 Where L is the number of leaf nodes and n is the number of internal nodes. Let us see following for examplek = 3Number of internal nodes n = 4Number of leaf nodes = (k-1)*n + 1 = (3-1)*4 + 1 = 9 Question 8 The following statement is valid. log(n!) = (n log n). True False Top MCQs on Complexity Analysis of Algorithms with Answers Top 50 Algorithms MCQs with Answers Discuss itQuestion 8-Explanation: Order of growth of \\log n! and n\\log n is the same for large values of , i.e., \\theta (\\log n!) = \\theta (n\\log n) . So time complexity of fun() is \\theta (n\\log n) . The expression \\theta (\\log n!) = \\theta (n\\log n) can be easily derived from following Stirling\'s approximation (or Stirling\'s formula). \\log n! = n\\log n - n +O(\\log(n))\\ Question 9 What is the time complexity of Floyd–Warshall algorithm to calculate all pair shortest path in a graph with n vertices? O(n2log(n)) Theta(n2log(n)) Theta(n4) Theta(n3) Top MCQs on Complexity Analysis of Algorithms with Answers Top 50 Algorithms MCQs with Answers Discuss itQuestion 9-Explanation: Floyd–Warshall algorithm uses three nested loops to calculate all pairs shortest path. So, the time complexity is Theta(n3).Please read here for more details. Question 10 Assuming P != NP, which of the following is true ? (A) NP-complete = NP(B) NP-complete P = (C) NP-hard = NP(D) P = NP-complete A B C D Top MCQs on NP Complete Complexity with Answers Top 50 Algorithms MCQs with Answers Discuss itQuestion 10-Explanation: The answer is B (no NP-Complete problem can be solved in polynomial time). Because, if one NP-Complete problem can be solved in polynomial time, then all NP problems can solved in polynomial time. If that is the case, then NP and P set become same which contradicts the given condition. Hence (B) is the correct answer. 12345 There are 50 questions to complete. You have completed questions question Your accuracy is Correct Wrong Partial-Credit You have not finished your quiz. If you leave this page, your progress will be lost. Correct Answer You Selected Not Attempted Final Score on Quiz Attempted Questions Correct Attempted Questions Wrong Questions Not Attempted Total Questions on Quiz Question Details Results Date Score Hint Time allowed minutes seconds Time used Answer Choice(s) Selected Question Text Need more practice! Keep trying! Not bad! Good work! Perfect! Last Updated : 26 Sep, 2023 Share your thoughts in the comments Add Your Comment Please Login to comment...