Download presentation

1
**Sorting algorithms Sieve of Eratosthenes**

Dr. Szczepan Paszkiel Department of Electrical, Control & Computer Engineering Institute of Control & Computer Engineering Opole University of Technology

2
**Sieve of Eratosthenes - pseudocode**

Input: an integer n > 1 Let A be an array of Boolean values, indexed by integers 2 to n, initially all set to true. for i = 2, 3, 4, ..., √n : if A[i] is true: for j = i2, i2+i, i2+2i, ..., n: A[j] := false Now all i such that A[i] is true are prime.

3
**Sieve of Eratosthenes flowchart**

YES Sieve of Eratosthenes flowchart NO a[i] = true - prime number a[i] = false - composite number NO YES

4
**Sieve of Eratosthenes in C++**

for(int i = 2; i <= N; i++) a[i] = 1; max = (int)sqrt(N); for(i = 2; i <= max; i++) if(a[i]==1) { j = i + i; while(j <= N) a[j] = 0; j += i; }

Similar presentations

OK

1 Flowchart If – Then – Else อนันต์ ผลเพิ่ม Anan Phonphoem

1 Flowchart If – Then – Else อนันต์ ผลเพิ่ม Anan Phonphoem

© 2018 SlidePlayer.com Inc.

All rights reserved.

By using this website, you agree with our use of **cookies** to functioning of the site. More info in our Privacy Policy and Google Privacy & Terms.

Ads by Google

Ppt on idiopathic thrombocytopenia purpura Ppt on chemical bonding and structures Ppt on pin diode switch Download ppt on statistics for class 11 Ppt on sound navigation and ranging system of a down Convert pps file to ppt online Ppt on national education policy 1986 monte Ppt on types of forests in india Ppt on pin diode limiter Ppt on mammals and egg laying animals are called