Algorithms
1. Which of the following searching algorithm is fastest?
a) binary search
b) linear search
c) jump search
d) all are equally fast
2. Where is linear searching used?
a) Used all the time
b) When the list has only a few elements
c) When performing a single search in an unordered list
d) When the list has only a few elements and When performing a single search in an
unordered list
3. Which of the following is not an application of binary search?
a) To search in unordered list
b) Debugging
c) Union of intervals
d) To find the lower/upper bound in an ordered sequence
4. Which of the following step is taken after finding an element having value greater than
the element being searched?
a) binary search takes place in the forward direction
b) binary search takes place in a backward direction
c) linear search takes place in the forward direction
d) linear search takes place in the backward direction
5. What is the advantage of recursive approach than an iterative approach?
a) Consumes less memory
b) Less code and easy to implement
c) Consumes more memory
d) More code has to be written
6. What is the worst case complexity of binary search using recursion?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)
7. What is the average case time complexity of binary search using recursion?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)
8. Binary Search can be categorized into which of the following?
a) Brute Force technique
b) Divide and conquer
c) Greedy algorithm
d) Dynamic programming
9. Which of the following sorting algorithms is the fastest for sorting small arrays?
a) Quick sort
b) Shell sort
c) Insertion sort
d) Heap sort
10. What is the advantage of selection sort over other sorting techniques?
a) It is faster than any other sorting technique
b) It is scalable
c) It works best for inputs which are already sorted
d) It requires no additional storage space
11. Which of the following method is used for sorting in merge sort?
a) partitioning
b) merging
c) exchanging
d) selection
12. Shell sort algorithm is an example of?
a) Bottom-up sorting
b) In-place sorting
c) Internal sorting
d) External sorting
13. Quick sort uses which of the following method to implement sorting?
a) partitioning
b) selection
c) exchanging
d) merging
14. In heap sort, after deleting the last minimum element, the array will contain elements
in?
a) increasing sorting order
b) tree preorder
c) tree inorder
d) decreasing sorting order
15. How many passes does an insertion sort algorithm consist of?
a) N
b) N-1
c) N+1
d) N2
16. Which of the following algorithm implementations is similar to that of an insertion
sort?
a) Binary heap
b) Quick sort
c) Merge sort
d) Radix sort
17. What is the average case running time of an insertion sort algorithm?
a) O(N)
b) O(N log N)
c) O(log N)
d) O(N2)
18. Any algorithm that sorts by exchanging adjacent elements require O(N2) on average.
a) True
b) False
19. What will be the number of passes to sort the elements using insertion sort?
14, 12,16, 6, 3, 10
a) 6
b) 5
c) 7
d) 1
20. For the following question, how will the array elements look like after second pass?
34, 8, 64, 51, 32, 21
a) 8, 21, 32, 34, 51, 64
b) 8, 32, 34, 51, 64, 21
c) 8, 34, 51, 64, 32, 21
d) 8, 34, 64, 51, 32, 21