Skip to content

Commit 5beb84a

Browse files
authored
Update README.markdown
when k > n/2 , we just need random select a.count - k elements and remove them from the original array
1 parent e14a46f commit 5beb84a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Selection Sampling/README.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ print(output.count)
193193

194194
The performance of this second algorithm is **O(n)** as it may require a pass through the entire input array.
195195

196-
> **Note:** If `k > n/2`, then it's more efficient to do it the other way around and choose `k` items to remove.
196+
> **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.
197197
198198
Based on code from Algorithm Alley, Dr. Dobb's Magazine, October 1993.
199199

0 commit comments

Comments
 (0)