From de496a2545c9755e02b49d1010e41490f1e7450c Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Fri, 22 Oct 2021 18:15:44 +0200 Subject: [PATCH] Update the cover for Weighted Random algorithm. --- src/algorithms/statistics/weighted-random/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/statistics/weighted-random/README.md b/src/algorithms/statistics/weighted-random/README.md index 8b9c8890..16e45970 100644 --- a/src/algorithms/statistics/weighted-random/README.md +++ b/src/algorithms/statistics/weighted-random/README.md @@ -59,7 +59,7 @@ const weightedItems = [ // And now just pick the random item from weightedItems array. ``` -However, as you may see, this approach may require a lot of memory, in case if the objects are heavy, and in case if we have a lot of them to repeat in `weightedItems` list. +However, as you may see, this approach may require a lot of memory, in case if we have a lot of items to repeat in `weightedItems` list. Think of it as if you would need to repeat a string like `"some-random-string"` (`18` bytes) a ten million times. You will need to allocate around `180Mb` of additional memory space just for this array. The **more efficient approach** would be to: