Searching in algorithm is a tactical or methodical approach to sorting and searching through data. There are two major ways of doing this: linear search and binary search. Binary search is sometimes called logarithmic search. But logarithmic search is just a method of doing binary search, not the binary search itself.
Binary Search
Say we have a group of data and we are looking for a particular values in it. Binary search is a search algorithm that finds the position of a target value within a sorted array . It involves sorting the data, and then constantly comparing the target value against the middle value. When this is done, the data is cut in half and the range where the data cannot be found, is eliminated, and the process is repeated again for the remaining portion of data until the target value is all that is left. Binary search is faster than linear
search except for small arrays. However, the array must be sorted first to be able to apply binary search.
Logarithmic Search
Logarithmic search is based on the o(log n) time complexity where n is the number of iterations. It is mostly found in recursive functions. Algorithms for which the running time is logarithmic are those where processing discards a large quantity of values in each iterations like in the binary search.
How they compare
As I mentioned before, Binary search is also called logarithmic search. This is because you can do it with a recursive function, recursive functions have a logarithmic time complexity. You can also perform a binary search by just iterations which is called an iterative method. Logarithmic algorithm can be used other things other than the binary search.
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)