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
Consider the following program segment and answer the questions given below:
int x[][] = {{2,4,5,6}, {5,7,8,1}, {34, 1, 10, 9}};(a) What is the position of 34?
(b) What is the result of x[2][3] + x[1][2]?
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
The statement used to find the total number of Strings present in the string array String s[] is:
- s.length
- s.length()
- length(s)
- len(s)