From 3c48e28855704711bab8b34d3070da582a698006 Mon Sep 17 00:00:00 2001 From: Ayan Joshi Date: Mon, 9 Oct 2023 02:17:22 +0530 Subject: [PATCH 1/2] Commit --- Sorting Visualizer/Readme.md | 28 +++++++++++ Sorting Visualizer/index.html | 19 +++++++ Sorting Visualizer/script.js | 94 +++++++++++++++++++++++++++++++++++ Sorting Visualizer/style.css | 66 ++++++++++++++++++++++++ 4 files changed, 207 insertions(+) create mode 100644 Sorting Visualizer/Readme.md create mode 100644 Sorting Visualizer/index.html create mode 100644 Sorting Visualizer/script.js create mode 100644 Sorting Visualizer/style.css diff --git a/Sorting Visualizer/Readme.md b/Sorting Visualizer/Readme.md new file mode 100644 index 000000000..c251dcdbd --- /dev/null +++ b/Sorting Visualizer/Readme.md @@ -0,0 +1,28 @@ +# Sorting-Visualizer +The Sorting Visualizer is a basic web application that allows you to visualize the process of sorting on a set of randomly generated bars. + +You can have a look , how it's working ! + +https://ayan-joshi.github.io/Sorting-Visualizer/ +# Technologies Used + +HTML + +CSS + +JavaScript + +# How to Use +Clone this repository to your local machine. + +Open index.html in your web browser. + +Click the "Randomize" button to generate a random set of bars. + +Select a sorting algorithm from the dropdown menu and click the "Sort" button to visualize the sorting process. + +# Screenshots + +![Screenshot 2023-08-03 203608](https://github.com/ayan-joshi/Sorting-Visualizer/assets/96243602/7ca1ebc1-42e7-47d7-a43f-4110fb769cce) + +![Screenshot 2023-08-03 203535](https://github.com/ayan-joshi/Sorting-Visualizer/assets/96243602/67209be1-5044-4cfa-beac-fb5ee129431d) \ No newline at end of file diff --git a/Sorting Visualizer/index.html b/Sorting Visualizer/index.html new file mode 100644 index 000000000..4b2404d58 --- /dev/null +++ b/Sorting Visualizer/index.html @@ -0,0 +1,19 @@ + + + + Sorting Visualizer + + + +

Sorting Visualizer

+
+ +
+ +
+ + +
+ + + diff --git a/Sorting Visualizer/script.js b/Sorting Visualizer/script.js new file mode 100644 index 000000000..7f30df140 --- /dev/null +++ b/Sorting Visualizer/script.js @@ -0,0 +1,94 @@ +const n = 20 +const array=[]; + +init(); + +let audioCtx=null; + +function playNote(freq){ + if(audioCtx==null){ + audioCtx=new( + AudioContext || + webkitAudioContext || + window.webkitAudioContext + )(); + } + const dur = 0.1; + const osc = audioCtx.createOscillator(); + osc.frequency.value=freq; + osc.start(); + osc.stop(audioCtx.currentTime+dur); + const node=audioCtx.createGain(); + node.gain.value=0.1; + node.gain.linearRampToValueAtTime( + 0, audioCtx.currentTime+dur + ); + osc.connect(node); + node.connect(audioCtx.destination); +} + + +function init(){ + for(let i=0;i array[i]){ + swapped = true; + moves.push({indices:[i-1,i],type:"swap"}); + [array[i-1],array[i]] = [array[i],array[i-1]]; + } + } + }while(swapped); + return moves; +} + +function showBars(move){ + container.innerHTML=""; + for(let i=0;i Date: Mon, 9 Oct 2023 14:12:30 +0530 Subject: [PATCH 2/2] Commit --- {Sorting Visualizer => SortingVisualizer/ayan-joshi}/Readme.md | 0 {Sorting Visualizer => SortingVisualizer/ayan-joshi}/index.html | 0 {Sorting Visualizer => SortingVisualizer/ayan-joshi}/script.js | 0 {Sorting Visualizer => SortingVisualizer/ayan-joshi}/style.css | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {Sorting Visualizer => SortingVisualizer/ayan-joshi}/Readme.md (100%) rename {Sorting Visualizer => SortingVisualizer/ayan-joshi}/index.html (100%) rename {Sorting Visualizer => SortingVisualizer/ayan-joshi}/script.js (100%) rename {Sorting Visualizer => SortingVisualizer/ayan-joshi}/style.css (100%) diff --git a/Sorting Visualizer/Readme.md b/SortingVisualizer/ayan-joshi/Readme.md similarity index 100% rename from Sorting Visualizer/Readme.md rename to SortingVisualizer/ayan-joshi/Readme.md diff --git a/Sorting Visualizer/index.html b/SortingVisualizer/ayan-joshi/index.html similarity index 100% rename from Sorting Visualizer/index.html rename to SortingVisualizer/ayan-joshi/index.html diff --git a/Sorting Visualizer/script.js b/SortingVisualizer/ayan-joshi/script.js similarity index 100% rename from Sorting Visualizer/script.js rename to SortingVisualizer/ayan-joshi/script.js diff --git a/Sorting Visualizer/style.css b/SortingVisualizer/ayan-joshi/style.css similarity index 100% rename from Sorting Visualizer/style.css rename to SortingVisualizer/ayan-joshi/style.css