Data Structures and Algorithms - Sorting and Searching

26. The number of possible commutative binary operations that can be defined on a set of n elements (for a given n) is

Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


27. The number of swappings needed to sort the numbers 8, 22, 7, 9, 31, 19, 5, 13 in ascending order, using bubble sort is

Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


28. The average successful search time taken by binary search on a sorted array of 10 items is

  • Option : D
  • Explanation : The 10 items i1, i2, ..., i10 may be arranged in a binary search tree as in Fig To get i5, the number of comparison needed is 1; for i2, it is 2; for i8 it is 2; for i1 it is 3, and so on. The average is (1+(2+2) +(3+3+3+3)+(4+4+4))/10, i.e., 2.9.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


29. The average successful search time for sequential search on 'n' items is

  • Option : C
  • Explanation : If the search key matches the very first item, with one comparison we can terminate. If it is second, two comparisons , etc. So, average is (1+2+...+n)/n .i.e. (n+1)/2
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


30. The running time of an algorithm T(n), where 'n' is the input size, is given by T(n) = 8T(n/2) + qn, if n>1 Where p,q are constants. The order of this algorithm is

Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *