AMP

chapter 6: Searching — Online MCQ Test

COMPUTER SCIENCE · CLASS 12 SECOND PUC · Karnataka State Board
Practice chapter 6: Searching with a free chapter-wise online MCQ test. This chapter covers: linear search - binary search. AI-generated questions from basic to board-exam level, with instant results and explanations.

Start Exam on Full Site →

chapter 6: Searching — Important Questions & Answers

Which searching technique checks each element of a list one by one until the required value is found?
  • A. Linear search
  • B. Binary search
  • C. Bubble search
  • D. Index search
Answer: A. Linear search
Linear search compares the target value with each element sequentially until a match is found or the list ends.
Binary search can be applied directly only when the data is:
  • A. Unsorted
  • B. Sorted
  • C. Stored only as strings
  • D. Stored only in a dictionary
Answer: B. Sorted
Binary search works by repeatedly dividing the search space into halves, which is possible only when the list is sorted.
A list contains [12, 25, 37, 44, 59]. If linear search is used to find 44, how many comparisons are needed?
  • A. 2
  • B. 3
  • C. 4
  • D. 5
Answer: C. 4
Linear search compares 44 with 12, 25, 37, and then 44, so 4 comparisons are required.
A sorted list has 16 elements. In the worst case, approximately how many comparisons are needed by binary search?
  • A. 2
  • B. 4
  • C. 16
  • D. 32
Answer: B. 4
Binary search takes about log2(n) comparisons; for 16 elements, log2(16) = 4 in the worst-case approximation.
For the sorted list [4, 8, 12, 16, 20, 24, 28, 32, 36], binary search is used to find 30. Which middle elements are checked before concluding not found?
  • A. 20, 28, 32
  • B. 20, 32, 28
  • C. 4, 8, 12, 16, 20, 24, 28, 32, 36
  • D. 16, 24, 32
Answer: A. 20, 28, 32
First 20 is checked, then the right half gives 28, and then 32. After that the search interval becomes empty, so 30 is not found.