Q:1. In a binary search algorithm, Which is the worst case scenario:-
Q:2. Which statement is correct in case of tower of hanoi ?
Q:3. How many swaps will be performed in selection sort in worst case :-
Q:4. Which of the following is true for binary search algorithm :-
Q:5. Which of the following statement is true for recursion ?
Ans 1:- O(logn)
In binary search, we eliminate half of the possible entries. So, worst case time complexity of binary search is logarithmic.
Ans 2 Only one disk can move at a time.
Rules for tower of hanoi is only one disk can move at a time.
Ans 3 n-1
selection sort gives the minimum number of swaps to sort an array.
Ans 4 Array can be sorted order
Binary Search works by assuming the middle of the array contains the middle value in the array.
Ans 5 Absence of base condition can cause infinte loop
needs a condition to terminate
0 Comments