algorithm - Binary Searching -
Therefore, I want to understand more about binary search, because I really can not understand. Binary search requires a pre-condition that has an array sorted. I got this right It seems that a method should check this pre-condition and throw an exception if it is not completed. But, why is a bad idea to check the prepaid?
This is a bad idea because the data is being sorted, it takes n
Step About the full search is the log (n)
step.
If you are going to check, you can also do linear search.
Comments
Post a Comment