Linear Search Recursive Multiple choice Questions and Answers (MCQs)
Is there any difference in the speed of execution between linear serach(recursive) vs linear search(lterative)?
Both execute at same speed
Linear search(recursive) is faster
Linear search(Iterative) is faster
Cant be said
Question 1 Explanation:
The Iterative algorithm is faster than the latter as recursive algorithm has overheads like calling function and registering stacks repeatedly.
Is the space consumed by the linear search(recursive) and linear search(iterative) same?
No, recursive algorithm consumes more space
No, recursive algorithm consumes less space
Nothing can be said
Question 2 Explanation:
The recursive algorithm consumes more space as it involves the usage the stack space(calls the function numerous times).
What is the worst case runtime of linear search(recursive) algorithm?
Question 3 Explanation:
In the worst case scenario, there might be a need of calling the stack n times. Therfore O(n).
Linear search(recursive) algorithm used in .....
When the size of the dataset is low
When the size of the dataset is large
When the dataset is unordered
Question 4 Explanation:
It is used when the size of the dataset is low as its runtime is O(n) which is more when compared to the binary search O(logn).
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)
Question 5 Explanation:
Provided that the search starts from the first element, the function calls itself till the element is found. In this case, the element is found in 4th call.
There are 5 questions to complete.