From e8cfdf2066c98dd24592687cde7042ecde09f81f Mon Sep 17 00:00:00 2001 From: kevin shah Date: Sat, 28 Oct 2023 13:17:23 +0530 Subject: [PATCH 1/2] added comment in WaterJug.js --- DSA/BFS/waterJug.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DSA/BFS/waterJug.js b/DSA/BFS/waterJug.js index 6d887d0..529d85b 100644 --- a/DSA/BFS/waterJug.js +++ b/DSA/BFS/waterJug.js @@ -132,4 +132,6 @@ function printSolution(node) { (() => { const [m, n, d] = [4, 3, 2]; solve(m, n, d); -})(); \ No newline at end of file +})(); + +// Demo Change \ No newline at end of file From 304d7dd95745279942a621a672c41011529d56dd Mon Sep 17 00:00:00 2001 From: kevin shah Date: Sat, 28 Oct 2023 13:32:25 +0530 Subject: [PATCH 2/2] created quick sort algo --- DSA/Arrays/QuickSort.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 DSA/Arrays/QuickSort.js diff --git a/DSA/Arrays/QuickSort.js b/DSA/Arrays/QuickSort.js new file mode 100644 index 0000000..b668065 --- /dev/null +++ b/DSA/Arrays/QuickSort.js @@ -0,0 +1,19 @@ +const quickSort = (arr) => { + if (arr.length <= 1) { + return arr; + } + + let pivot = arr[0]; + let leftArr = []; + let rightArr = []; + + for (let i = 1; i < arr.length; i++) { + if (arr[i] < pivot) { + leftArr.push(arr[i]); + } else { + rightArr.push(arr[i]); + } + } + + return [...quickSort(leftArr), pivot, ...quickSort(rightArr)]; + }; \ No newline at end of file