Linear Search VS Binary Seach - Which One You Prefer ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Linear Search VS Binary Seach - Which One You Prefer ?

As linear seach can be done in one line ( using python ) where as binary search takes some exta line so why people choose linear over binary as the time complexity of binary is much better than linear search

3rd Oct 2019, 12:56 PM
m8riix
m8riix - avatar
4 Answers
+ 4
Yes, there is no need to sort the list first for the linear search.
3rd Oct 2019, 1:53 PM
Sonic
Sonic - avatar
+ 3
maybe the list is not sorted and it is not huge list.
3rd Oct 2019, 1:04 PM
voja
voja - avatar
+ 2
maybe people prefer simplicity over time complexity, i can understand why.
3rd Oct 2019, 1:00 PM
Taste
Taste - avatar
0
If you using the sorted values use Binary Search
3rd Oct 2019, 5:05 PM
Islombek
Islombek - avatar