-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added the article draft for binary search
- Loading branch information
1 parent
28926e1
commit fc6175a
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!-- BEGIN TITLE --> | ||
# Search Smarter Not Harder | ||
<!-- END TITLE --> | ||
|
||
<!-- BEGIN BODY --> | ||
What would you do, if you are given a list of sorted entries and asked to find a particular one? | ||
You could read through the list, until you find the correct entry. | ||
However, if the list has one million entries, you might have to read all of them until you find what you are looking for! | ||
|
||
What if you skipped to the middle of the list and answered the following question: | ||
"Does the entry I am looking for belong in the first or second half of the list?" | ||
Whatever the answer, you now only have to consider 500 000 entries. | ||
By repeating this process, you can halve the number of possible entries again. | ||
If you keep doing this, you will have to read at most $log_2(1000000) \approx 20$ entries! | ||
|
||
Computer Scientists call the first approach "linear search" and the second "binary search". Formally the runtimes (how many entries you have to read) are $O(n)$ and $O(log(n))$, where $n$ is the number of entries. | ||
<!-- END BODY --> | ||
|
||
![illustration.png](../binary-search/illustration.png) | ||
|
||
<!-- BEGIN AUTHOR --> | ||
Carina Schrenk | ||
Philippe Leon-Marius Gottfrois | ||
<!-- END AUTHOR --> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.