MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
The search algorithm(s) which can be implemented using recursive approach is/are
A
Linear search
B
Binary search
C
Both Linear Search and Binary Search
D
No search algorithms
Explanation: 

Detailed explanation-1: -Binary search is a recursive algorithm. The high level approach is that we examine the middle element of the list. The value of the middle element determines whether to terminate the algorithm (found the key), recursively search the left half of the list, or recursively search the right half of the list.

Detailed explanation-2: -Binary search is an inherently recursive algorithm: we can implement iteratively, but it makes more sense algorithmicly to do it recursively (though for certain implementations you might choose to do it iteratively for efficiency reasons). Binary search works by splitting up a sorted data set into two parts.

Detailed explanation-3: -A recursive algorithm to search for a key in a BST follows immediately from the recursive structure: If the tree is empty, we have a search miss; if the search key is equal to the key at the root, we have a search hit. Otherwise, we search (recursively) in the appropriate subtree.

Detailed explanation-4: -Binary search follows the divide and conquer approach in which the list is divided into two halves, and the item is compared with the middle element of the list. If the match is found then, the location of the middle element is returned.

There is 1 question to complete.