shay.co blog
From the monthly archives: October 2011
Today I came across an algorithmic problem.
I wanted to choose a random sub array of size \(k\) from an array of size \(n\), while maintaining its order.
For example, if we have the array \(\{0,1,2,3,4,5,6,7,8,9\}\) a possible result for \(k=4\) is the array \(\{1,4,7,9\}\).
I came up with an algorithm with average [...]
Categories
