Computer Applications
What is the difference between the linear search and the binary search technique?
Java Arrays
ICSE 2019
31 Likes
Answer
Linear search | Binary search |
---|---|
Linear search works on sorted and unsorted arrays. | Binary search works on only sorted arrays. |
In Linear search, each element of the array is checked against the target value until the element is found or end of the array is reached. | In Binary search, 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
18 Likes
Related Questions
Write a Java program to store n numbers in an one dimensional array. Pass this array to a function number(int a[]). Display only those numbers whose sum of digit is prime.
What is the output of the Java code given below?
String color[] = {"Blue", "Red", "Violet"}; System.out.println(color[2].length());
- 6
- 5
- 3
- 2