[sort] Quick sort, 퀵 소트- 1 pivot
function quickSort(arr) { quickSortRecursivley(arr, 0, arr.length - 1); return arr; } function quickSortRecursivley(arr, s, e) { if (s >= e) return; const pivotIndex = partition(arr, s, e); quickSortRecursivley(arr, pivotIndex + 1, e); quickSortRecursivley(arr, s, pivotIndex - 1); } function partition(arr, s, e) { let pivot = e; let left = s; let right = e; let pointer = left; let pivotNumber = ..
2023. 4. 5.
[subset] find all subsets
Number of Subsets of a given Set: If a set contains ‘n’ elements, then the number of subsets of the set is 2n. Number of Proper Subsets of the Set: If a set contains ‘n’ elements, then the number of proper subsets of the set is 2n - 1. | If A = {p, q} the proper subsets of A are [{ }, {p}, {q} with loop const nums = [1, 2, 3]; const subsets = [[]]; function findSubsets(subsets, nums, currentSet,..
2022. 12. 25.