Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6f8a077

Browse files
committed
Link to Khan Academy video showing exponent and logarithm as inverses.
1 parent c4c0f86 commit 6f8a077

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎binary_search/README.markdown‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The important pattern to notice is that the number of possible correct answers (
3939

4040
Notice that in the second example, however, we didn't even need to use a third guess, because there was only one possible answer after the second guess. Three guesses is the *slowest* it would take to find the answer in a set of eight items, not the fastest. This is still potentially much faster than a worst-case scenario if we used a *linear* search instead of a *binary* search. If we used a linear search, it would have taken us 8 guesses to guess the number 8 in the first example if we started guessing at 1, because our next guess would have been 2, then 3, and so on.
4141

42-
Binary search is also sometimes called *logarithmic search* because the search speed is calculatable by taking a logarithm of the length of the list. A logarithm is the opposite of an exponent. 2 raised to the power of 3 (that is, 2 multiplied by itself 3 times) equals eight (2<sup>3</sup> = 8). We can retrieve the exponent (the 3, which is the most guesses we'd need to search an 8-item list) by applying the logarithm function to the number 8 (the size of our search space) with a base of 2 (because we're halving the space at each guess): log<sub>2</sub>8 = 3.
42+
Binary search is also sometimes called *logarithmic search* because the search speed is calculatable by taking a logarithm of the length of the list. [A logarithm is the opposite of an exponent](https://www.khanacademy.org/math/algebra-home/alg-exp-and-log/alg-graphs-of-logarithmic-functions/v/comparing-exponential-logarithmic-functions). 2 raised to the power of 3 (that is, 2 multiplied by itself 3 times) equals eight (2<sup>3</sup> = 8). We can retrieve the exponent (the 3, which is the most guesses we'd need to search an 8-item list) by applying the logarithm function to the number 8 (the size of our search space) with a base of 2 (because we're halving the space at each guess): log<sub>2</sub>8 = 3.
4343

4444
Using logarithmic math, you can easily find out how many guesses it would take you to find a given item in an arbitrarily large search space. For instance, if you had to guess a number between 1 and 100, it would take you at most log<sub>2</sub>100 guesses if you always halved the search space at each guess (i.e., if you "used binary search").
4545

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /