-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e155f1d
Showing
25 changed files
with
1,126 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,14 @@ | ||
|
||
|
||
root = true | ||
|
||
|
||
[*] | ||
insert_final_newline = true | ||
end_of_line = lf | ||
|
||
|
||
[*.{md,js,css,html}] | ||
indent_style = space | ||
indent_size = 4 | ||
charset = utf-8 |
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,53 @@ | ||
|
||
name : Deploy the visualization page to GitHub Pages | ||
|
||
|
||
# Only rebuild the page if something | ||
# changes in the /Source/ folder. | ||
|
||
on: | ||
workflow_dispatch: # Allow manual starting | ||
push: | ||
branches: | ||
- 'main' | ||
|
||
paths: | ||
- 'Source/**' | ||
|
||
|
||
permissions: | ||
id-token : write | ||
contents : read | ||
pages : write | ||
|
||
|
||
concurrency: | ||
cancel-in-progress : true | ||
group : 'pages' | ||
|
||
|
||
jobs: | ||
deploy: | ||
|
||
environment: | ||
name : github-pages | ||
url : ${{ steps.deployment.outputs.page_url }} | ||
|
||
runs-on : ubuntu-latest | ||
|
||
steps: | ||
|
||
- name : Checkout | ||
uses : actions/checkout@v3 | ||
|
||
- name : Setup Pages | ||
uses : actions/configure-pages@v2 | ||
|
||
- name : Upload artifact | ||
uses : actions/upload-pages-artifact@v1 | ||
with : | ||
path : 'Source/' | ||
|
||
- name : Deploy to GitHub Pages | ||
uses : actions/deploy-pages@v1 | ||
id : deployment |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 David Kobalia | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,62 @@ | ||
|
||
<br> | ||
|
||
<div align = center> | ||
|
||
# Sorting Algorithms | ||
|
||
*Visualization of a variety of sorting algorithms.* | ||
|
||
<br> | ||
<br> | ||
|
||
[![Button Website]][Website] | ||
|
||
<br> | ||
<br> | ||
|
||
</div> | ||
|
||
## Algorithms | ||
|
||
*List of algorithms used on the page.* | ||
|
||
- **[Insertion Sort]** | ||
|
||
- **[Selection Sort]** | ||
|
||
- **[Counting Sort]** | ||
|
||
- **[Cocktail Sort]** | ||
|
||
- **[Bubble Sort]** | ||
|
||
- **[Gnome Sort]** | ||
|
||
- **[Quick Sort]** | ||
|
||
- **[Heap Sort]** | ||
|
||
- **[Bogo Sort] a.k.a. Monkey Sort** | ||
|
||
<br> | ||
|
||
|
||
<!-----------------------------------------------------------------------------> | ||
|
||
[Website]: https://Insuetus.github.io/sorting_algos | ||
|
||
[Insertion Sort]: https://en.wikipedia.org/wiki/Insertion_sort | ||
[Selection Sort]: https://en.wikipedia.org/wiki/Selection_sort | ||
[Counting Sort]: https://en.wikipedia.org/wiki/Counting_sort | ||
[Cocktail Sort]: https://en.wikipedia.org/wiki/Cocktail_shaker_sort | ||
[Bubble Sort]: https://en.wikipedia.org/wiki/Bubble_sort | ||
[Gnome Sort]: https://en.wikipedia.org/wiki/Gnome_sort | ||
[Quick Sort]: https://en.wikipedia.org/wiki/Quicksort | ||
[Heap Sort]: https://en.wikipedia.org/wiki/Heapsort | ||
[Bogo Sort]: https://en.wikipedia.org/wiki/Bogosort | ||
|
||
|
||
<!---------------------------------[ Buttons ]---------------------------------> | ||
|
||
[Button Website]: https://img.shields.io/badge/Website-7D929E?style=for-the-badge&logoColor=white&logo=ApacheCouchDB |
Binary file not shown.
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,30 @@ | ||
|
||
import { Sorted, Unsorted, Alpha, Beta } from 'Colors' | ||
|
||
|
||
export default function* (size, items) { | ||
|
||
for (let i = 0; i < size - 1; i++) { | ||
|
||
for (let j = 0; j < size - i - 1; j++) { | ||
|
||
yield [Alpha, j] | ||
yield [Beta, j + 1] | ||
|
||
if (items[j] > items[j + 1]) { | ||
|
||
[items[j], items[j + 1]] = [items[j + 1], items[j]]; | ||
|
||
yield [Beta, j] | ||
yield [Alpha, j + 1] | ||
} | ||
|
||
yield [Unsorted, j] | ||
yield [Unsorted, j + 1] | ||
} | ||
|
||
yield [Sorted, size - 1 - i] | ||
} | ||
|
||
yield [Sorted, 0] | ||
} |
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,66 @@ | ||
|
||
import { Sorted, Unsorted, Alpha, Beta } from 'Colors' | ||
|
||
|
||
export default function* (size, items) { | ||
|
||
let | ||
swapped = true, | ||
lsize = size, | ||
index = 0; | ||
|
||
while (swapped) { | ||
|
||
swapped = false; | ||
|
||
for (let i = index; i < lsize - 1; ++i) { | ||
|
||
yield [Alpha, i] | ||
yield [Beta, i + 1] | ||
|
||
if (items[i] > items[i + 1]) { | ||
|
||
[items[i], items[i + 1]] = [items[i + 1], items[i]]; | ||
|
||
yield [Beta, i] | ||
yield [Alpha, i + 1] | ||
|
||
swapped = true; | ||
} | ||
|
||
yield [Unsorted, i] | ||
yield [Unsorted, i + 1] | ||
} | ||
|
||
swapped = false; | ||
lsize--; | ||
|
||
for (let i = lsize - 1; i >= index; i--) { | ||
|
||
yield [Alpha, i] | ||
yield [Beta, i + 1] | ||
|
||
if (items[i] > items[i + 1]) { | ||
|
||
[items[i], items[i + 1]] = [items[i + 1], items[i]]; | ||
|
||
yield [Beta, i] | ||
yield [Alpha, i + 1] | ||
|
||
swapped = true; | ||
} | ||
|
||
yield [Unsorted, i] | ||
yield [Unsorted, i + 1] | ||
} | ||
|
||
yield [Sorted, index] | ||
|
||
index++ | ||
|
||
yield [Sorted, lsize] | ||
} | ||
|
||
for (let i = 0; i < size; i++) | ||
yield [Sorted, i] | ||
} |
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,51 @@ | ||
|
||
import { Sorted, Unsorted, Alpha, Beta } from 'Colors' | ||
|
||
|
||
export default function* (size, items) { | ||
const counter = {} | ||
let max = -1, | ||
max_index = 0, | ||
min = 10e6, | ||
min_index = 0; | ||
|
||
for (let i = 0; i < size; i++) { | ||
yield [Alpha, i]; | ||
if (items[i] > max) { | ||
max = items[i]; | ||
max_index = i; | ||
} | ||
if (items[i] < min) { | ||
min = items[i]; | ||
min_index = i; | ||
} | ||
if (items[i] in counter) | ||
counter[items[i]].push(i); | ||
else | ||
counter[items[i]] = [i]; | ||
} | ||
|
||
yield [Beta, max_index] | ||
yield [Beta, min_index] | ||
let c = 0, | ||
replaced_index, | ||
old_items = [...items]; | ||
for (let i = min; i <= max; i++) { | ||
if (!(i in counter)) continue; | ||
while (counter[i].length) { | ||
replaced_index = counter[i].pop(); | ||
yield [Alpha, c]; | ||
yield [Beta, replaced_index]; | ||
yield [Unsorted, c]; | ||
yield [Unsorted, replaced_index]; | ||
[items[c], old_items[replaced_index]] = [old_items[replaced_index], items[c]]; | ||
yield [Beta, replaced_index]; | ||
yield [Sorted, c++]; | ||
} | ||
} | ||
|
||
for (let i = 0; i < size; i++) { | ||
yield [Sorted, i]; | ||
} | ||
|
||
} |
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,28 @@ | ||
|
||
import { Sorted, Unsorted, Alpha, Beta } from 'Colors' | ||
|
||
|
||
export default function* (size, items) { | ||
|
||
let index = 0; | ||
|
||
while (index < size) { | ||
|
||
if (items[index] >= items[index - 1] || index == 0) { | ||
|
||
yield [Alpha, index] | ||
yield [Sorted, index] | ||
|
||
index++; | ||
|
||
} else { | ||
|
||
[items[index], items[index - 1]] = [items[index - 1], items[index]]; | ||
|
||
yield [Beta, index] | ||
yield [Unsorted, index + 1] | ||
|
||
index--; | ||
} | ||
} | ||
} |
Oops, something went wrong.