The array is as follows: 1,2,3,6,8,10. At what time the element 6 is found?…

2024

The array is as follows: 1,2,3,6,8,10. At what time the element 6 is found? (By using linear search(recursive) algorithm)

  1. A.

    4th call

  2. B.

    3rd call

  3. C.

    6th call

  4. D.

    5th call

Attempted by 78 students.

Show answer & explanation

Correct answer: A

Answer: a

Explanation: In recursive linear search, the function starts from the first element (index 0) and makes a recursive call for each element until the target is found. The array is 1, 2, 3, 6, 8, 10. The element 6 is at index 3 (0-based). The first call checks index 0, second checks index 1, third checks index 2, and fourth checks index 3. Thus, the element is found in the 4th call.

Explore the full course: Coding For Placement