5 ms·
Thanks for pointing it out. Should clearly not depend on the number of iterations. It's fixed now.
by dmitrim 9y ago
Thanks for pointing it out. Should clearly not depend on the number of iterations. It's fixed now.
- fauigerzigerk 9y agoI think there's another bug in the generateSlice function if the intention is to create a slice with n random numbers. func generateSlice(n int) []int { s := make([]int, n) for i := 0; i < n; i++ { s = append(s, rand.Intn(1e9)) } return s } As it is now, the function creates a slice with n zeros followed by n random numbers. I suppose you meant to say make([]int, 0, n). You could just as well assign directly to each slice element instead of using append, which would be more efficient. I made the exact same mistake quite a few times myself.
- dmitrim 9y agoYep, that meant to be capacity, not length. Corrected. Thanks!