[ HOME ] [ UP ] [ TM ] [ RAM ] [ Sequence ] [ Skip List ] [ Search ] [ Josephus ] [ SOE ] [ PCP ] [ Hanoi ] [ Queens ] [ Maze ] [ RPN ] [ Pattern ] [ Huffman ] [ BST ] [ AVL ] [ Splay ] [ Red-Black ] [ B-Tree ] [ Trie ] [ Quadtree ] [ Heap ] [ PQ ] [ Hashing ] [ Sorting ] [ Insertionsort ] [ Mergesort ] [ Shellsort ] [ Heapsort ] [ Tournamentsort ] [ Quicksort ] [ Binsort ] [ Radixsort ] [ Graph Traversal ] [ Critical Path ] [ Shortest Path ] [ MST ] [ Maxflow ] [ DynaProg ] [ DSN ] [ TSP ]


Sieve of Erastothenes


Sieve of Erastothenes@Oregonstate

Prime numbers are found by Sieve of Erastosthenes as follows:

  • A bit map is an array of bits.
  • A bit map is implemented as a BitSet in Java.
  • Each number smaller than or equal to N is represented by one bit in the Bitsetp of size N + 1. The bit for a number is 0 if the number is a prime.
  • Otherwise, it is 1.
  • 0 and 1 are non-prime numbers, and 2 is a prime number.
  • Multiples of each prime number is marked nond-prime numbers.
  • All the prime numbers between 2 and N / 2 are considered.

(Courtesy of http://web.engr.oregonstate.edu/~minoura/cs261/)



TOP

[ HOME ] [ UP ] [ TM ] [ RAM ] [ Sequence ] [ Skip List ] [ Search ] [ Josephus ] [ SOE ] [ PCP ] [ Hanoi ] [ Queens ] [ Maze ] [ RPN ] [ Pattern ] [ Huffman ] [ BST ] [ AVL ] [ Splay ] [ Red-Black ] [ B-Tree ] [ Trie ] [ Quadtree ] [ Heap ] [ PQ ] [ Hashing ] [ Sorting ] [ Insertionsort ] [ Mergesort ] [ Shellsort ] [ Heapsort ] [ Tournamentsort ] [ Quicksort ] [ Binsort ] [ Radixsort ] [ Graph Traversal ] [ Critical Path ] [ Shortest Path ] [ MST ] [ Maxflow ] [ DynaProg ] [ DSN ] [ TSP ]

Copyleft (c) 2003-3002, Junhui Deng
Last updated on 05.30.2012