Create a list and simply implement enqueue and dequeue

Assignment Help Web Project
Reference no: EM132080130

You need the Html and javaScript separate. You need a working jsfiddle please

Assignment

You are going to create a Queue. (alternately you can create a list and simply implement enqueue and dequeue functions in the List - that will technically make it a queue).

You will fill the first list with numbers consecutively numbered from 2 to n where n is entered by the user (we will call this Q1). When creating your Queue object use the correct function names for enqueue and dequeue functions.

Again - sorry, cannot use an Javascript array in your implementation - you need to implement enqueue and dequeue.

Create a second empty Queue Q2.

Once you have the first Queue filled we are going to use a technique called Sieve of Eratosthenes which uses first queue to fill the second queue.

Here is the algorithm;

1. Dequeue 1st element in Q1 (which will be 2). You will need to remember the value of this element - we will call it X.

2. Enqueue this element into Q2 (Q2 is the list of primes)

3. Iterate and Dequeue each successive element of Q1

If the value is divisible by X, go to the next element

if the value is not divisible by X enqueue back onto Q1, go to the next element.

4. Print the values of Q1 and Q2 after each time through.

5. When done go back to the beginning of the Q1 and repeat steps 1-3 (the first value will be 3 the second time around)

Sample output with input 10

Iteration 0: Q1 = 2 3 4 5 6 7 8 9 10, Q2 = ,

Iteration 1: Q1 = 3 5 7 9, Q2 = 2

Iteration 2: Q1 = 5 7, Q2 = 2 3

Iteration 3: Q1 = 7, Q2 = 2 3 5

Iteration 4: Q1 = , Q2 = 2 3 5 7

Reference no: EM132080130

Questions Cloud

Create a linked list that is a palindrome : Create a linked list that is a Palindrome, and call the isPalindrome method. Test to ensure it returns True.
Demand and supply curves for a good : With this type of externality, in the absence of government intervention, the market equilibrium quantity produced will be (Greather/less) than the socially
Write a program that will convert distance measurements : Write a C++ program that will convert distance measurements from miles to kilometers.
Devise a scoring system for each objective : ENGINEERING DESIGN - DESIGN REPORT - EVALUATION - THE WEIGHTED OBJECTIVE METHOD - Teesside University - Calculate scores and weighted scores for each car
Create a list and simply implement enqueue and dequeue : Create a Queue. Fill the first list with numbers consecutively numbered from 2 to n where n is entered by the user .
What is the maximum range : The world long jump record is 8.95 m (Mike Powell, USA, 1991). Treated as a projectile, what is the maximum range (in m) obtainable by a person if he has a take
What is the average density of the full gas can : What is the average density of the full gas can, taking into account the volume occupied by steel as well as by gasoline
What temperature is needed : Suppose you want the atoms in your fusion experiment to have average kinetic energies of 6.4 x 10^-14 J. What temperature is needed?
Push on opposite sides of a door during play : Two children push on opposite sides of a door during play. Both push horizontally and perpendicular to the door.

Reviews

Write a Review

Web Project Questions & Answers

  Evaluating an ecommerce website

Create a check list that contains key point for evaluating an ecommerce website - Write a short, reflective report about website

  Gpc and runtime magic quotes

Create a script that lets you know whether Zeus or Helios has the GPC and Runtime Magic Quotes turned on or off. The output should have appropriate labels that define what output signified and should display 'ON' or 'OFF' depending on the setting.

  Creating functions through conditional operator

Use the conditional operator and the cal_days_in_month function, determine the number of days in the current month and output to browser whether it is normal month or a leap month.

  Web development projects with database

Since the vast majority of web-development projects involve a database, do you think that computational activities should be performed there, or do you think they belong in the XML page or stylesheet?

  Comparing shelf software packages

Required assistance with comparing and contrasting two main off the shelf software packages that could be implemented in an organization.

  Web based scams

Web phishing, pharming and vishing are popular web based scams. Talk about currently used tools and recommended measures to defeat this kind of attacks efficiently?

  Explanation of contextual links

The most powerful hypertext capabilities is the the contextual link. Wikipedia . com is a great example of a site that utilizes contextual links.

  How architectural and protocol changes occur

Discuss how architectural and protocol changes happen, the administrative organization that oversees the technical development of the Internet,

  Traditional approaches for training professionals

Webinars and other web conferencing techniques have proved most beneficial for the provision of affordable quality corporate training.

  Internet for business

Discuss how can a business use the Internet and give at least three examples with web links demonstrating your answer.

  It influences the behavior of organizations

Information technology influences the behavior of organizations. Name one effect of Information technology implementation and long-term usage you suppose having a positive contribution and one having a negative consequence.

  Importance of a guided navigation system

Explain the use and importance of a guided navigation system and shopping cart for a website designed for e-commerce and business purpose.

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