KnowledgeBoat Logo
|
LoginJOIN NOW

Computer Applications

What is the difference between linear search and binary search ?

Java Arrays

3 Likes

Answer

Linear SearchBinary Search
Linear search works on sorted and unsorted arrays.Binary search works only on sorted arrays (both ascending and descending).
Each element of the array is checked against the target value until the element is found or end of the array is reached.Array 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 slower.Binary Search is faster.

Answered By

3 Likes


Related Questions