Linear Search On Sorted Array

preview_player
Показать описание
Linear Search On Sorted Array
Watch More Videos at:
Lecture By: Mr. Arnab Chakraborty, Tutorials Point India Private Limited.
Рекомендации по теме
Комментарии
Автор

instead of coparing for loc=-1 you can use break it will automaticlly braks the loops if item is found else it will run until item is smaller than than the indexed item.
so
for (i=0, i<n&&a[i]<=item, i++)
{if a[i]=item
loc=i
return loc
}
return loc

infiwebtech
Автор

What about time complexity and space complexity

syedmainudeen