# Linear Search Recursive – Multiple Choice Questions and Answers (MCQs)

This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs) focuses on “Linear Search Recursive”.

**1. The array is as follows: 1,2,3,6,8,10. Given that the number 17 is to be searched. At which call it tells that there’s no such element? (By using linear search(recursive) algorithm)****A) 7th call**

B) 9th call

C) 17th call

D) The function calls itself infinite number of times**Explanation: **If the element is located, the function calls itself. However, when it reaches the seventh call, it terminates because it is outside the list.

**2. What is the best case runtime of linear search(recursive) algorithm on an ordered set of elements?****A) O(1)**

B) O(n)

C) O(logn)

D) O(nx)

E**xplanation:** When the given element to be found is in the first place, the best case scenario occurs. As a result, O(1) is the correct answer.

**3. Which of the following code snippet performs linear search recursively?**

A)

for(i=0;i<n;i++) { if(a[i]==key) printf("element found"); }

**B)**

LinearSearch(int[] a, n,key) { if(n<1) return False if(a[n]==key) return True else LinearSearch(a,n-1,key) }

C)

LinearSearch(int[] a, n,key) { if(n<1) return True if(a[n]==key) return False else LinearSearch(a,n-1,key) }

D)

LinearSearch(int[] a, n,key) { if(n<1) return False if(a[n]==key) return True else LinearSearch(a,n+1,key) }

**Explanation: **n should be compared to the first element in arr[]. Return the element if it is located in the first place. Otherwise, repeat for the remaining sequence and n.

**4. Can linear search recursive algorithm and binary search recursive algorithm be performed on an unordered list?****A) Binary search can’t be used**

B) Linear search can’t be used

C) Both cannot be used

D) Both can be used**Explanation:** Since binary search necessitates comparison, the list must be ordered. For linear search, however, this is irrelevant.

**5. What is the recurrence relation for the linear search recursive algorithm?**

A) T(n-2)+c

B) 2T(n-1)+c**C) T(n-1)+c**

D) T(n+1)+c**Explanation:** The size of n is reduced by one after each call in the recursive algorithm. As a result, T(n-1)+c is the best solution.

**6. Is there any difference in the speed of execution between linear serach(recursive) vs linear search(lterative)?**

A) Both execute at same speed

B) Linear search(recursive) is faster**C) Linear search(Iterative) is faster**

D) Cant be said**Explanation: **The iterative algorithm is faster than the recursive algorithm because the recursive algorithm has overheads such as constantly calling functions and registering stacks.

**7. Is the space consumed by the linear search(recursive) and linear search(iterative) same?****A) No, recursive algorithm consumes more space**

B) No, recursive algorithm consumes less space

C) Yes

D) Nothing can be said**Explanation: **The recursive algorithm takes up more space since it makes use of the stack space (calls the function numerous times).

**8. What is the worst case runtime of linear search(recursive) algorithm?****A) O(n)**

B) O(logn)

C) O(n^{2})

D) O(nx)**Explanation: **In the worst-case situation, the stack can need to be called n times. As a result (n).

**9. Linear search(recursive) algorithm used in _____________****A) When the size of the dataset is low**

B) When the size of the dataset is large

C) When the dataset is unordered

D) Never used**Explanation: **It is used when the dataset size is small since its runtime is O(n), which is faster than the binary search O(n) (logn).

**10. 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)****A) 4th call**

B) 3rd call

C) 6th call

D) 5th call**Explanation: **If the quest begins with the first element, the function will keep calling itself until the element is found. The element is found in the fourth call in this case.

Recursion is a problem-solving technique in which the solution is based on the answers to smaller instances of the same problem. Iteration can usually solve such problems, but it requires identifying and indexing the minor cases at programming time. Recursive techniques are effective at solving one of the most basic problems in computer science: searching. We’ll look at two different search algorithms: linear search and binary search. Linear search compares the current element to the search element by searching at data in a sequential manner.