Javascript -- 2

Assignment 1.

In Javascript we are going to create a Class called Chain. If you need a little primer on creating objects and classes in Javascript see [url removed, login to view] - if you know your object oriented code this will be relatively straightforward. Your Chain will be made up of Links. Each link will have an id, a value (String) and a pointer to the next link ( NextLink ) - which is simply a pointer to the id of the next link in the Chain. Please note that this is a very inefficient representation of the Chain. Here is a simple Javascript code definition of a Link for you to use. [url removed, login to view]

You will make a Chain consisting of 5 links. You will also create a print function for the chain that will print the links in link order. You may need to create some functions to support this functionality.

Assignment 2.

Implement a Stack computer in Javascript (you will turn in a link to your program in JSFiddle). This is a simple computer that keeps a stack, when a number is entered it goes onto the top of the stack. When an operation is entered, the previous 2 numbers are operated on by the operation.

For example

2 [enter] 2

5 [enter] 5 2

* [enter] * 5 2 -> collapses to 10

would leave at 10 at the top of the stack.

The program should use a simple input box, either a text field or prompt and display the contents of the Stack.

Question: What kind of structure and algorithm is needed to make a game like this?

Assignment 3

You are going to create a List. You will then fill it with numbers consecutively numbered from 2 to n where n is entered by the user.

Create a second List - this one should be a Queue - it is empty.

Once you have the first List filled we are going to use a technique called Sieve of Eratosthenes which uses first queue to fill the second queue. You will need to look at the algorithm for this [url removed, login to view]

Here is the simple method to do this - L1 is the first list, Q1 is the Queue.

1. Go to 1st element in L1 (which will be 2).

2. Because it exists - Push this into Q1 and remove it from L1

3. Iterate through each element of L1 and if the value is divisible by 2 remove it.

4. When done go back to the beginning of the list (the value will be 3 the second time around)

5. Print Iteration 1, Value of L1 (all elements) and Q1 (all elements)

6. Repeat steps 2-5 with this new element - repeat until L1 is empty.

Sample output with input 10

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

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

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

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

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

Skills: HTML, Javascript

See more: what is the sieve of eratosthenes, what is the definition of algorithm, what is algorithm in computer, what is a computer algorithm, w3schools html 5, the sieve of eratosthenes, straightforward algorithm, simple algorithm example, sieve of eratosthenes in c code, sieve of eratosthenes example, sieve of eratosthenes code, sieve of eratosthenes c code, sieve of eratosthenes c, sieve of eratosthenes, sieve of, sieve numbers, sieve number definition, sieve number 4, sieve no, sieve code

About the Employer:
( 16 reviews ) port orange, United States

Project ID: #8026306

Awarded to:


We are new at freelance but have vast experience. We have team of web designer and developer who developed 30+ web site with different technology. You can check my portfolio [login to view URL] thanks WebcodeZ Inf More

$25 USD in 1 day
(2 Reviews)

3 freelancers are bidding on average $28 for this job


Hi, I am online now. Give me all details and let start now. Contact me by chat. Have a nice day. Bye

$30 USD in 3 days
(1 Review)

Hello, Happy to have your attention and thanks for this wonderful opportunity. I am very good in ajax,jquery, javascript : please see me on elance too : [login to view URL] Recently I have de More

$30 USD in 3 days
(1 Review)