मराठी
महाराष्ट्र राज्य शिक्षण मंडळएचएससी विज्ञान (संगणक विज्ञान) इयत्ता १२ वी

Write difference between Linear Search and Binary Search.

Advertisements
Advertisements

प्रश्न

write difference between Linear Search and Binary Search.

फरक स्पष्ट करा
Advertisements

उत्तर

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)
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 8: Arrays - Sort & Search - Exercises [पृष्ठ १९७]

APPEARS IN

रूपा पंडित Computer Applications [English] Class 10 ICSE
पाठ 8 Arrays - Sort & Search
Exercises | Q 2. (ii) | पृष्ठ १९७
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×