DEV Community

Discussion on: Trees and the Database.

 
dwakelknight profile image
♠ รєใ๏г๓ คv๏кє †

Yes it was. I was just comparing to see opposite ends were the same. Typically in a search like this you will most like have a worst case. The smaller the number the harder to find but the since it's index is far. And the higher the number the higher you are in you array and closer to your destination so the best case scenario mostly be bit so great ever with binary search tree

Thread Thread
 
er_dward profile image
Internet Explorer

Well making double of the numbers means more space will be taken.. So on large datasets it will take more memory. (space complexity). Now lets imagine if the number is not in there... for example looking for 10. You will iterate through the whole numbers. from index 1 to .. arr.Length. Which is what you will likely not prefer.

Thread Thread
 
dwakelknight profile image
♠ รєใ๏г๓ คv๏кє †

Oh okay, so that means like nothing will really change in time complexity as opposed to running two different for loops from the opposite ends of the array; the only difference will be in space complexity of the variables that hold the arr.index if either situation, I variable in the first (new implementation) and 2 variables in using traditional method of two loops