English

Write difference between Linear Search and Binary Search.

Advertisements
Advertisements

Question

write difference between Linear Search and Binary Search.

Distinguish Between
Advertisements

Solution

Sr. No. Linear Search Binary Search
1 Linear search performs on unsorted list of elements as well as a sorted list. For binary search, the elements in the array are stored alphabetically or numerically.
in a sorted manner.
2 Compare the desired element with all elements in an array until the match is found. Compare the value of the midpoint with the desired value. If the value is greater than the midpoint value, the first half is checked.
Otherwise, the second half checked until the search is successful or the interval is empty.
3 Insertion of an element in an array can be performed very efficiently when the array is not ordered. An insertion of a new element requires that many elements be physically moved to preserve order.
4 For large size of array, time
required for this search is very
larger.
For a large size of array, comparatively, the time required is less.
5 Time complexity is as follows:
Worst case: N comparisons
Best case: 1 comparison
Time complexity as follows:
Worst case: log2 N comparison
Best case: 1 comparison
shaalaa.com
Basic Data Structures (Stack, Queue, Dequeue)
  Is there an error in this question or solution?
Chapter 8: Arrays - Sort & Search - Exercises [Page 197]

APPEARS IN

Rupa Pandit Computer Applications [English] Class 10 ICSE
Chapter 8 Arrays - Sort & Search
Exercises | Q 2. (ii) | Page 197
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×