Saturday, October 27, 2007

Binary Search Interview Question Part 2


17.Which of the following searching method runs most efficiently utilising the memory for already sorted file?
a. Binary search
b. Index sequential search
c. Sequential search with array implementation
d. Sequential search with linked list implementation
Ans. a


18.To search a single item from a group of 8 sorted items how many checks are required in Binary Search
a.8 b.4 c.3 d.2
Ans:c
Since 2*2*2=8

19.To search a page number 364 in a book containing 500 pages which of the following Searching technique should be used to reach the page in minimum time?
a.Linear search
b.Fibonacci search
c.Binary search
d.Random search
Ans:c

20. Consider the set of integers given below.

2,3,5, 7,11, 13, 17 ,19, 23, 29
How many comparisons are required to search when key value is equal to 23 using a binary search algorithm.
a.1 b.2 c.3 d.4
Ans:c

First comparison identifies middle element 0+9/2=4.5
4th element is 11.
2nd comparison gives 19 and 3rd 23.

21.What kind of search is used in a telephone directory?
a.Linear search
b.Binary search
c.Hashing
d.none
Ans:b

22. Which of the following statements is/are incorrect in connection with the binary search algorithm?
(a) The most efficient method of searching a sequential table without the use of auxiliary indices or tables is the binary search algorithm.
(b) Basically, the argument is compared with the key of the middle element of the table. If they are equal, the search is successful; otherwise, either the upper half or the lower half of the table must be searched in a similar manner.
(c) Any kind of data set can be used.
(d) Time complexity is O (n log n).
Ans: c
23. Binary search algorithm works best with
a) Arrays
b) trees
c) Binary Search trees
d) None
Ans:c

24. What additional requirement is placed on an array, so that binary search may be used to locate an entry?
A. The array elements must form a heap.
B. The array must have at least 2 entries.
C. The array must be sorted.
D. The array's size must be a power of two.
Ans:c
25. What is the worst-case time for serial search finding a single item in an array?
A. Constant time
B. Logarithmic time
C. Linear time
D. Quadratic time
Ans:c

26. If there are 17 elements in an array, how many maximum comparisons are required to search an element using binary search?
a.3 b.4 c.5 d.6
Ans:c

27.If there are 34 elements in an array, how many maximum comparisons are required to search an element using binary search?
a.3 b.4 c.5 d.6
Ans:d

0 comments:

Advertisement

 

Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com