退出

Is the Seive of Eratosthens a Breadth First Search Algorithm?

数论 Math StackExchange 0 票 0 回答 6 浏览 提问者: WhyNotMath 2026-06-11 00:36
number-theory graph-theory primality-test

问题内容

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

  1. Start with a finite list of integers from 2 to the maximum.
  2. Mark multiples of the smallest prime number and remove them from the list.
  3. Repeat this process with the next smallest unmarked number until all numbers are marked.

Breadth First Search

  1. Start with a root node and explore all neighbors.
  2. Explore all neighbors of these neighbors
  3. Continue level by level.

Does this make sense?

回答 (0)

暂无回答记录。