Advertisements
Advertisements
प्रश्न
How is linear search different from binary search?
अंतर स्पष्ट करें
Advertisements
उत्तर
| Basis of Difference | Linear Search | Binary Search |
|---|---|---|
| Method | Checks elements one by one from the beginning. | Checks the middle element and repeatedly halves the search range. |
| Requirement | Works on sorted as well as unsorted lists. | Requires the list to be sorted. |
| Speed | Slower for large lists. | Faster for large sorted lists. |
| Comparisons | May compare every element. | Makes far fewer comparisons by eliminating half the list at each step. |
| Best use | Small or unsorted lists. | Large sorted lists. |
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
