Presentation is loading. Please wait.

Presentation is loading. Please wait.

Common Array Algorithms

Similar presentations


Presentation on theme: "Common Array Algorithms"— Presentation transcript:

1 Common Array Algorithms
AP Java Common Array Algorithms

2 Learning Targets Be able to use common array algorithms to solve challenges. Improve in focused note taking strategies

3 Array Algorithms Common Array Algorithms Link
Complete the fill in blanks on the web pages Take focused notes as needed.(Cornell, Outline, mapping, … Select a strategy to implement) Next weeks Exam will be open notes. (Anything you write down you can use. Not print out!)

4 Boolean Array Program (12/14/2018)
Use an array to calculate and show all prime numbers <=1000 Use the sieve of Eratosthenes Write a program to use this process in finding all primes less than or equal to 1000. How many primes will Java let you find using this method? Cross out 1, because it is not prime. Circle 2, because it is the smallest positive even prime. Now cross out every multiple of 2; in other words, cross out every second number. Circle 3, the next prime. Then cross out all of the multiples of 3; in other words, every third number. Some, like 6, may have already been crossed out because they are multiples of 2. Circle the next open number, 5. Now cross out all of the multiples of 5, or every 5th number. Continue doing this until all the numbers through 100 have either been circled or crossed out. You have just circled all the prime numbers from 1 to 100!

5 Getting Started Creating an array of Booleans
boolean[] seive = new boolean[1000]; Initializing them to true (potentially prime). for( int i = 0; i < seive.length; i++ ) seive[i] = true ;


Download ppt "Common Array Algorithms"

Similar presentations


Ads by Google