0% found this document useful (0 votes)
36 views

Placement Questions: Searching

The document discusses various searching and sorting algorithms. It provides definitions and analyzes the time complexity of different algorithms like linear search, binary search, insertion sort, selection sort, quicksort, heapsort and merge sort. It also provides examples of their applications and compares their performance in best, average and worst cases.

Uploaded by

SANTOSH GUPTA
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Placement Questions: Searching

The document discusses various searching and sorting algorithms. It provides definitions and analyzes the time complexity of different algorithms like linear search, binary search, insertion sort, selection sort, quicksort, heapsort and merge sort. It also provides examples of their applications and compares their performance in best, average and worst cases.

Uploaded by

SANTOSH GUPTA
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Placement Questions

Searching:

1. Everyelementinthedatasetisexaminedintheorderpresenteduntil thevaluebeingsearchedforis found;


the following technique is calledas
a. Binarysearch.
b. Quicksearch.
c. Linearsearch.
d. None ofthese.

Ans:c

2. Best case time complexity of Sequential searchis


a. O(1)
b. O(n)
c. O(n×n)
d. None ofthese.

Ans:a
3. Average case time complexity of Sequential searchis
a. O(1)
b. O(n)
c. O(n×n)
d. None ofthese.
Ans:b
4. Worst case time complexity of Sequential searchis
a. O(1)
b. O(n)
c. O(n×n)
d. None ofthese.

Ans:b
5. Best case time complexity of linear searchis
a. O(1)
b. O(n)

34
c. O(n×n)
d. None ofthese.
Ans:a
6. Average case time complexity of linear searchis
a. O(1)
b. O(n)
c. O(n×n)
d. None ofthese.
Ans:b
7. Worst case time complexity of Linear searchis
a. O(1)
b. O(n)
c. O(n×n)
d. None ofthese.

Ans:b
8. Efficiency is usually measured in terms of abstract computations,such as data moves and
the memory used. True.

9. Binary search is a more specialized algorithm than sequential search as it takes advantage
of data that hasbeen
a. Sorted
b. NotSorted
c. random
d. none of theabove
Ans:a

10. The underlying idea of binary search is to divide the sorted data into two halves and to
examine the data at the point of the split.True.

11. Binary search when compared to linear searchis


a. Moreefficient
b. Lessefficient
c. slower
d. none

35
Ans:a

12. A search algorithm is an algorithm that accepts an argument a and tries to find a record in
the file with the primary key as a.True.

13. Binary search is a part of or used in which of thefollowing


a. binary insertionsort
b. idealsearch
c. suffixarray
d. all theabove
Ans:d

14. Binary search is akindof .


Ans. dichotomic search

15. strategy is a part of or used in binarysearch.


Ans. Divide and conquer

16. The run time of binary searchis


a. O(lnn)
b. O(n lnn)
c. O(logn)
d. O(n)
Ans. a
The run time of binary search is O(ln n) which is log n to the base e.

17. For finding the middle element in a binary search to avoid overflows the formula usedis
Ans. mid = low + (high-low)/2

18. The mid element of a binary search can be found by usingtherelation .


Ans. mid = (high + low)/2

Sorting:
1. Which of the following is not a stable sortingalgorithm?
a) Insertionsort
b) Selectionsort
c) Bubblesort
d) Mergesort

36
Ans. B
2. Which of the following is a stable sortingalgorithm?
a) Mergesort
b) Typical in-place quicksort
c) Heapsort
d) Selectionsort

Ans: A
3. Which of the following is not an in-place sortingalgorithm?
a) Selectionsort
b) Heapsort
c) Quicksort
d) Mergesort

Ans: D
4. Running merge sort on an array of size n which is already sortedis
a) O(n)
b) O(nlogn)
c) O(n2)
d) None
Ans: B
5. Thetimecomplexityofaquicksortalgorithmwhichmakesuseofmedian,foundbyan
O(n) algorithm, as pivot elementis
a) O(n2)
b) O(nlogn)
c) O(nloglogn)
d) O(n)

Ans: B
6. Which of the following is not a noncomparisonsort?
a) Countingsort
b) Bucketsort
c) Radixsort
d) Shellsort

37
Ans: D
7. The time complexity of heap sort in worst caseis
a) O(logn)
b) O(n)
c) O(nlogn)
d) O(n2)

Ans: C
8. Ifthegiveninputarrayissortedornearlysorted,whichofthefollowingalgorithmgivestheb
est performance?
a) Insertionsort
b) Selectionsort
c) Quicksort
d) Mergesort

Ans: A
9. Which of the following algorithm pays the least attention to the ordering of the elements
in theinput list?
a) Insertionsort
b) Selectionsort
c) Quicksort
d) None
Ans: B
10. Which of the following algorithms has lowest worst case timecomplexity?
a) Insertionsort
b) Selectionsort
c) Quicksort
d) Heapsort
Ans: D

38

You might also like