Program to find prime number from linked list, JAVA Programming

Assignment Help:

For this assignment you are provided with a class called LNode which can be used as a list node for a linked list of ints. You are also provided with an abstract class called LList which uses the LNode class. The LList class describes a linked list implementation and contains two implemented methods and five abstract methods.

1. Create a subclass of LList called MyLList

2. Implement all of the abstract methods from LList in your MyLList class

3. Write a class called Sieve which contains two MyLList data variables called seedList and primeList and which implements the simplified Sieve algorithm given below:

Consider the task of finding all prime numbers up to a given maximum number.

Prime numbers are integers that have no factors other than 1 and themselves. The number 2 is the smallest prime number. The sieve of Eratosthenes (named for the Ancient Greek mathematician who devised it) is a classic algorithm for finding prime numbers. The sieve algorithm starts by creating two lists of numbers: one list of numbers (the seed list) to process (some of which may be prime) and another list of numbers (the primes list) which is the list of numbers known to be prime. Initially the seed list of numbers to process contains every number from 2 up to a defined maximum while the primes list is empty, e.g. if the defined maximum is 15 the starting state for the two lists is:

seedList : (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)

primeList : ( )

The sieve algorithm begins by removing the first element from the seed list and adding it the primes list (this number is guaranteed to be prime due to the nature of the algorithm). Next, the algorithm filters out all of the elements in the seed list which are multiples of the prime number which has just been removed.

On the first pass of the algorithm, for example, the number 2 is selected from the seed list and added to the primes list, then all multiples of 2 are removed from the seed list. The lists now look as follows:

seedList : (3, 5, 7, 9, 11, 13, 15)

primeList : (2)

Now the number 3 is at the head of the seed list. On the next pass of the algorithm 3 will be moved to the primes list and all multiples of 3 will be removed from the seed list so that the lists look like:

seedList : (5, 7, 11, 13)

primeList : (2, 3)

The process continues until the seed list is empty at which point the primes list will contain all known primes up to the given maximum as follows:

seedList : ( )

primeList : (2, 3, 5, 11, 13)

4. When your sieve program is run it should prompt the user to enter a maximum value (which must be smaller than 500). It should then run the sieve algorithm (as described above) with the given number as the defined maximum. Finally it should output the contents of the prime list.

A sample run of your program should look as follows:

Enter a maximum value:

Primes list up to 25 is: 2, 3, 5, 7, 11, 13, 17, 19, 23 where 25 is the value entered by the user.

Please use the given naming conventions for your classes and do not make any changes to LNode.java and LList.java

This assignment is worth 10% of your final grade, marks will be allocated as follows:

  • Correctly implementing the MyLList class
  • Correctly handling input and output for the sieve class
  • Correctly implementing the sieve algorithm
  • Structure of code and comments

If you are unclear about any of this information, please ask.


Related Discussions:- Program to find prime number from linked list

Computer application and program, Computer application and program. Proj...

Computer application and program. Project Description: I require a project done. It is a computer desktop application program. It is not very hard. Skills required: Any

What are the advantages of multimedia presentations, What are the advantage...

What are the advantages of multimedia presentations? Write any five. Multimedia presentation is a excellent tool for effective communication: Advantages: 1. Easy to make l

Develop a java application, Project Description: Modules of software: ...

Project Description: Modules of software: 1 - Serial RS232 comm port comunication 2 - NanoHTTPD serving some processed pages 3 - System tray application to indicate sta

Whatsapp bulk messenger to unlimited numbers, hi,i need whatsapp panel to s...

hi,i need whatsapp panel to send unlimitd message. skype : maya123.com email :

Explain the member access separator, Explain the Member Access Separator ? ...

Explain the Member Access Separator ? class Car { String licensePlate; // e.g. "New York 543 A23" double speed; // in kilometers per hour double maxSpeed; // in

Describe methods of basic applet life cycle, Describe methods of Basic Appl...

Describe methods of Basic Applet Life Cycle ? All applets have the subsequent four methods: public void init(); public void start(); public void stop(); public void destroy();

Why do we call javascript an object-based language, Why do we call JavaScri...

Why do we call JavaScript an Object-based Language? In java language an JavaScript shares several similarities with object-oriented languages, and thus is known as an object-ba

La food, The fancy new French restaurant La Food is very popular for its au...

The fancy new French restaurant La Food is very popular for its authentic cuisine and high prices. This restaurant does not take reservations. To help improve the efficiency of the

Explain all java primitive data types, Explain all Java Primitive Data Type...

Explain all Java Primitive Data Types? boolean 1-bit. May take on the values true and false only. true and false are describe constants of the language and are not the s

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd