Comment Comment by thesz This is so trivial!Actually, if you use lazy data structures, then sorting the list lazily and taking i-th element will give you the best possible complexity: http://en.wikipedia.org/wiki/Selection_algorithm#Language_su...In Haskell, it is nothing more than "ithSmallest xs i = sort xs !! i". parent thesz 13 years ago
Actually, if you use lazy data structures, then sorting the list lazily and taking i-th element will give you the best possible complexity: http://en.wikipedia.org/wiki/Selection_algorithm#Language_su...
In Haskell, it is nothing more than "ithSmallest xs i = sort xs !! i".