Computer Applications
What is the difference between linear search and binary search ?
Java Arrays
3 Likes
Answer
Linear Search | Binary 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
Show the contents of the array after the second iteration of Selection Sort.
Show the contents of the array after the second iteration of Bubble Sort.
Given the following array :
Which sorting algorithm would produce the following result after three iterations
Given the following array :
Which sorting algorithm would produce the following result after three iterations.