4GuysFromRolla.com HeadlinesHeadlines for 4GuysFromRolla.com. 4Guys is an online resource site for ASP and ASP.NET information!Techniques for Randomly Reordering an Array- July 2, 2008 While reading through some of Jeff Atwood's old blog entries, I stumbled across this gem: The Danger of Naivete. In it, Jeff discussed the pitfalls the can befall a programmer who implements a naive algorithm and calls it a day. Consider an algorithm to randomly reorder an array. If you have a collection of items to reorder, the naive approach is to enumerate each element and swap its position with an element in some other randomly-selected position. However, such an algorithm (as we discuss...http://aspnet.4guysfromrolla.com/articles/070208-1.aspx |