what I don't still understand is:
//pseudo code
int a[5] = {10,20,30,40, 45}
bool search (int a[5], int value) {
for (int i=0; i< a.lenght; i++)
if (value == a[i]) return true;
return false;
}
search (45); -> this is what'll happen in the worst case. And it's O(n).......and array was sorted.....It isn't O(logN)
//pseudo code
int a[5] = {10,20,30,40, 45}
bool search (int a[5], int value) {
for (int i=0; i< a.lenght; i++)
if (value == a[i]) return true;
return false;
}
search (45); -> this is what'll happen in the worst case. And it's O(n).......and array was sorted.....It isn't O(logN)
To copy to clipboard, switch view to plain text mode
Bookmarks