Skip to content

Commit

Permalink
added the article draft for binary search
Browse files Browse the repository at this point in the history
  • Loading branch information
carinaschrenk committed Oct 19, 2024
1 parent 28926e1 commit fc6175a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions 2024/binary-search/article.md
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 -->









Binary file added 2024/binary-search/illustration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fc6175a

Please sign in to comment.