COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]

The worst case occurs in linear search algorithm when ____

Item is not in the array at all


Item is somewhere in the middle of the array


Item is the last element in the array or item is not there at all


Item is the last element in the array

Explanation:
Detailed explanation1: The worst case occurs in the Linear Search Algorithm when the item to be searched is in end of the Array.
Detailed explanation2: For Linear Search, the worst case happens when the element to be searched (x) is not present in the array. When x is not present, the search() function compares it with all the elements of arr[] one by one. Therefore, the worstcase time complexity of the linear search would be O(n).
Detailed explanation3: Time Complexity of Linear Search The worstcase time complexity is O(n), if the search element is found at the end of the array, provided the size of the array is n.
There is 1 question to complete.