Design And Analysis Of Algorithms Set 3

On This Page

This set of Design and Analysis of Algorithms Multiple Choice Questions & Answers (MCQs) focuses on Design And Analysis Of Algorithms Set 3

Q1 | What is the time complexity of the program to reverse stack when linked list is used for its implementation?
  • o(n)
  • o(n log n)
  • o(n2)
  • o(log n)
Q2 | Which of the following takes O(n) time in worst case in array implementation of stack?
  • pop
  • push
  • isempty
  • pop, push and isempty takes constant time
Q3 | What will be the time complexity of the code to reverse stack recursively?
  • o(n)
  • o(n log n)
  • o(log n)
  • o(n2)
Q4 | Which of the following sorting algorithm has best case time complexity of O(n2)?
  • bubble sort
  • selection sort
  • insertion sort
  • stupid sort
Q5 | Which of the following is the biggest advantage of selection sort?
  • its has low time complexity
  • it has low space complexity
  • it is easy to implement
  • it requires only n swaps under any condition
Q6 | What will be the recurrence relation of the code of recursive selection sort?
  • t(n) = 2t(n/2) + n
  • t(n) = 2t(n/2) + c
  • t(n) = t(n-1) + n
  • t(n) = t(n-1) + c
Q7 | Which of the following sorting algorithm is NOT stable?
  • selection sort
  • brick sort
  • bubble sort
  • merge sort
Q8 | What will be the best case time complexity of recursive selection sort?
  • o(n)
  • o(n2)
  • o(log n)
  • o(n log n)
Q9 | Recursive selection sort is a comparison based sort.
  • true
  • false
Q10 | What is the average case time complexity of recursive selection sort?
  • o(n)
  • o(n log n)
  • o(n2)
  • o(log n)
Q11 | What is the bidirectional variant of selection sort?
  • cocktail sort
  • bogo sort
  • gnome sort
  • bubble sort
Q12 | Which of the following methods can be used to find the largest and smallest element in an array?
  • recursion
  • iteration
  • both recursion and iteration
  • no method is suitable
Q13 | What is the number of swaps required to sort the array arr={5,3,2,4,1} using recursive selection sort?
  • 0
  • 1
  • 2
  • 3
Q14 | Which of the following methods can be used to find the largest and smallest number in a linked list?
  • recursion
  • iteration
  • both recursion and iteration
  • impossible to find the largest and smallest numbers
Q15 | Which of the following techniques can be used to search an element in an unsorted array?
  • iterative linear search
  • recursive binary search
  • iterative binary search
  • normal binary search
Q16 | Consider the array {1,1,1,1,1}. Select the wrong option?
  • iterative linear search can be used to search for the elements in the given array
  • recursive linear search can be used to search for the elements in the given array
  • recursive binary search can be used to search for the elements in the given array
  • no method is defined to search for an element in the given array
Q17 | What is the time complexity of the above recursive implementation of binary search?
  • o(n)
  • o(2n)
  • o(logn)
  • o(n!)
Q18 | Which of the following methods can be used to search an element in a linked list?
  • iterative linear search
  • iterative binary search
  • recursive binary search
  • normal binary search
Q19 | Can binary search be applied on a sorted linked list in O(Logn) time?
  • no
  • yes
Q20 | Recursive program to raise an integer x to power y uses which of the following algorithm?
  • dynamic programming
  • backtracking
  • divide and conquer
  • greedy algorithm
Q21 | What is the least time in which we can raise a number x to power y?
  • o(x)
  • o(y)
  • o(log x)
  • o(log y)
Q22 | What is the advantage of iterative code for finding power of number over recursive code?
  • iterative code requires less time
  • iterative code requires less space
  • iterative code is more compiler friendly
  • it has no advantage
Q23 | Recursive approach to find power of a number is preferred over iterative approach.
  • true
  • false
Q24 | What is the objective of tower of hanoi puzzle?
  • to move all disks to some other rod by following rules
  • to divide the disks equally among the three rods by following rules
  • to move all disks to some other rod in random order
  • to divide the disks equally among three rods in random order
Q25 | Recurrence equation formed for the tower of hanoi problem is given by                    
  • t(n) = 2t(n-1)+n
  • t(n) = 2t(n/2)+c
  • t(n) = 2t(n-1)+c
  • t(n) = 2t(n/2)+n