Computer Applications
What is the difference between the linear search and the binary search technique?
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. |
Related Questions
Name the below structure:

- One dimensional array
- Two Dimensional array with 4 rows and 5 columns
- Three dimensional array
- Two Dimensional array with 5 rows and 4 columns
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.
A single dimensional array has 50 elements, which of the following is the correct statement to initialize the last element to 100.
- x[51]=100
- x[48]=100
- x[49]=100
- x[50]=100