Created
November 11, 2020 14:55
-
-
Save sungchuni/baeb994f146c89bbf8cdafc12f64fec8 to your computer and use it in GitHub Desktop.
무작위 정렬을 수행할 것이라 예상하는 방식이 얼만큼 무효한지를 검증하기 위한 함수
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
function computeAverageRandomSort(length = 16, iteration = 1024) { | |
function generateRandomArray() { | |
return Array.from({length}) | |
.map((_, i) => i) | |
.sort(() => Math.random() - .5); | |
} | |
const arrays = Array.from({length: iteration}).map(generateRandomArray); | |
return Array.from({length}).map( | |
(_, i) => | |
arrays.map(array => array[i]).reduce((sum, value) => sum + value) / iteration | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment