Skip to content

Commit

Permalink
rebuilding site Friday 26 April 2024 07:42:19 PM IST
Browse files Browse the repository at this point in the history
  • Loading branch information
animesh-chouhan committed Apr 26, 2024
1 parent 2dad5c2 commit 94e238d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions DeepThought/content/posts/sleepsort.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tags = ["python", "dsa"]
<!-- more -->

<p align="center">
<img src="/images/posts/sleepsort/sleepsort.png" alt="sleepsort" style="max-width:80%"/>
<img src="/images/posts/sleepsort/sleepsort.png" alt="sleepsort" style="max-width:90%"/>
</p>

## Sorting Algorithms
Expand All @@ -31,7 +31,7 @@ Sleep sort is a fun and quirky way to sort numbers. It was thought up by someone
This photo of the original 4chan post was taken from this [Princeton Lecture](https://www.cs.princeton.edu/courses/archive/fall13/cos226/lectures/52Tries.pdf).

<p align="center">
<img src="/images/posts/sleepsort/sleepsort-4chan.jpg" alt="sleepsort" style="max-width:80%"/>
<img src="/images/posts/sleepsort/sleepsort-4chan.jpg" alt="sleepsort" style="max-width:90%"/>
</p>

It's not the fastest way to sort numbers, but it's interesting because it's so different. Imagine organizing numbers like you're hitting the snooze button on an alarm clock!
Expand All @@ -41,7 +41,7 @@ It's not the fastest way to sort numbers, but it's interesting because it's so d
Unlike regular sorting methods that compare and swap numbers, sleep sort does things differently. It relies on the scheduler, which handles tasks running at the same time. Sleep sort works by using this scheduler to time when each number should join the sorted list.

<p align="center">
<img src="/images/posts/sleepsort/async-eventloop.jpg" alt="sleepsort" style="max-width:80%"/>
<img src="/images/posts/sleepsort/async-eventloop.jpg" alt="sleepsort" style="max-width:90%"/>
</p>

Every modern operating system includes a scheduler, a vital component responsible for managing the execution of various tasks or processes running concurrently. These tasks can range from handling user input to managing system resources efficiently.
Expand Down Expand Up @@ -90,7 +90,7 @@ This implementation utilizes the asynchronous nature of `asyncio` to simulate th
Here's the output when we run this Python script:

<p align="center">
<img src="/images/posts/sleepsort/sleepsort.gif" alt="sleepsort-demo" style="max-width:90%"/>
<img src="/images/posts/sleepsort/sleepsort.gif" alt="sleepsort-demo" style="max-width:95%"/>
</p>

## Can we make it any faster?
Expand Down
8 changes: 4 additions & 4 deletions posts/sleepsort/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ <h1 class="title">
<div class="content mt-2">
<!-- Add summary here -->
<span id="continue-reading"></span><p align="center">
<img src="/images/posts/sleepsort/sleepsort.png" alt="sleepsort" style="max-width:80%"/>
<img src="/images/posts/sleepsort/sleepsort.png" alt="sleepsort" style="max-width:90%"/>
</p>
<h2 id="sorting-algorithms">Sorting Algorithms</h2>
<p>Sorting algorithms are like the organizers of the computer world, quietly putting everything in order. They help arrange data neatly, whether it's a list of names or scores.</p>
Expand All @@ -227,13 +227,13 @@ <h2 id="sleep-sort">Sleep Sort</h2>
<p>Sleep sort is a fun and quirky way to sort numbers. It was thought up by someone on 4Chan in 2011. Instead of the usual sorting methods, this one makes each number &quot;sleep&quot; for a bit before joining the sorted list. So, if a number is 3, it waits for 3 units of time before settling into its place.</p>
<p>This photo of the original 4chan post was taken from this <a rel="noopener nofollow noreferrer" target="_blank" href="https://www.cs.princeton.edu/courses/archive/fall13/cos226/lectures/52Tries.pdf">Princeton Lecture</a>.</p>
<p align="center">
<img src="/images/posts/sleepsort/sleepsort-4chan.jpg" alt="sleepsort" style="max-width:80%"/>
<img src="/images/posts/sleepsort/sleepsort-4chan.jpg" alt="sleepsort" style="max-width:90%"/>
</p>
<p>It's not the fastest way to sort numbers, but it's interesting because it's so different. Imagine organizing numbers like you're hitting the snooze button on an alarm clock!</p>
<h2 id="dependency-on-scheduler">Dependency on Scheduler</h2>
<p>Unlike regular sorting methods that compare and swap numbers, sleep sort does things differently. It relies on the scheduler, which handles tasks running at the same time. Sleep sort works by using this scheduler to time when each number should join the sorted list.</p>
<p align="center">
<img src="/images/posts/sleepsort/async-eventloop.jpg" alt="sleepsort" style="max-width:80%"/>
<img src="/images/posts/sleepsort/async-eventloop.jpg" alt="sleepsort" style="max-width:90%"/>
</p>
<p>Every modern operating system includes a scheduler, a vital component responsible for managing the execution of various tasks or processes running concurrently. These tasks can range from handling user input to managing system resources efficiently.</p>
<p>This reliance on the scheduler not only distinguishes sleep sort from conventional sorting methods but also underscores the algorithm's dependency on system-level mechanisms for its operation.</p>
Expand Down Expand Up @@ -272,7 +272,7 @@ <h2 id="python-implementation">Python Implementation</h2>
<p>This implementation utilizes the asynchronous nature of <code>asyncio</code> to simulate the sleep sort algorithm, where each number &quot;sleeps&quot; for a duration proportional to its value before being added to the sorted list.</p>
<p>Here's the output when we run this Python script:</p>
<p align="center">
<img src="/images/posts/sleepsort/sleepsort.gif" alt="sleepsort-demo" style="max-width:90%"/>
<img src="/images/posts/sleepsort/sleepsort.gif" alt="sleepsort-demo" style="max-width:95%"/>
</p>
<h2 id="can-we-make-it-any-faster">Can we make it any faster?</h2>
<p>The sole drawback of this algorithm lies in the time consumed during the sleep intervals, which is capped by the highest number within the unsorted input. How can we reduce this sleep delay?</p>
Expand Down

0 comments on commit 94e238d

Please sign in to comment.