From 5beb84acec563fefef04ce87683484e4359f5350 Mon Sep 17 00:00:00 2001 From: Keith Date: Wed, 31 Jan 2018 23:40:15 +0800 Subject: [PATCH] Update README.markdown when k > n/2 , we just need random select a.count - k elements and remove them from the original array --- Selection Sampling/README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Selection Sampling/README.markdown b/Selection Sampling/README.markdown index ff80791e1..741f592f4 100644 --- a/Selection Sampling/README.markdown +++ b/Selection Sampling/README.markdown @@ -193,7 +193,7 @@ print(output.count) The performance of this second algorithm is **O(n)** as it may require a pass through the entire input array. -> **Note:** If `k > n/2`, then it's more efficient to do it the other way around and choose `k` items to remove. +> **Note:** If `k > n/2`, then it's more efficient to do it the other way around and choose `a.count - k` items to remove. Based on code from Algorithm Alley, Dr. Dobb's Magazine, October 1993.