Comment

Comment by cpeterso

Raymond’s selectRandomFromIterator algorithm requires iterating over all the files. It seems like querying the file system for the number of files in a directory should be an O(1) operation. Then you just select random number N between [1, number of files] and iterate to the Nth file.

Why does Raymond assume counting the files is an O(n) operation?

parent cpeterso 1 month ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton