Liner search to find the index of an element which has occurred multiple times
Answers
Answered by
0
Answer:
Linear search is rarely used practically because other search algorithms such as the binary search algorithm and hash tables allow significantly faster-searching comparison to Linear search.
Improve Linear Search Worst-Case Complexity
if element Found at last O(n) to O(1)
It is the same as previous method because here we are performing 2 ‘if’ operations in one iteration of the loop and in previous method we performed only 1 ‘if’ operation. This makes both the time complexities same.
Similar questions