Computer Applications

Differentiate between Linear search and Binary search

Java Arrays

65 Likes

Answer

Linear SearchBinary Search
Linear search works on sorted and unsorted arraysBinary search works on only sorted arrays (ascending or descending)
Each element of the array is checked against the target value until the element is found or end of the array is reachedArray is successively divided into 2 halves and the target element is searched either in the first half or in the second half
Linear Search is slowerBinary Search is faster

Answered By

43 Likes


Related Questions