Is the Seive of Eratosthens a Breadth First Search Algorithm?
问题内容
Numbers that are not yet mapped to are marked prime and given their own "trees", but really they are distance $\infty$ from the other primes.
Traditionally, in a connected graph, BFS forms one tree, but really this is a collection of overlapping trees.
What we have on the number line is a disconnected graph by definition because (for example) there is no directed path from 2 to 7. So this is a (di)graph theoretic look at primality.
Seive of Eratosthens
- Start with a finite list of integers from 2 to the maximum.
- Mark multiples of the smallest prime number and remove them from the list.
- Repeat this process with the next smallest unmarked number until all numbers are marked.
Breadth First Search
- Start with a root node and explore all neighbors.
- Explore all neighbors of these neighbors
- Continue level by level.
Does this make sense?
回答 (0)
暂无回答记录。