Must be done in JSfiddle
Project 1.
An interpolation table is a specific instance of a Lookup Table - which is also a practical application of indexing, in this case numeric indexes. You will create a computer program that uses the following lookup table (interpolation table), allows a user to input a number and calculates the answer by interpolating between 2 numbers - or finds an exact solution.
0 0.00
1 0.04
2 0.11
3 0.60
4 0.87
5 0.95
6 1.00
The table gives the amount of total rainfall (normalized to 1) that occurred during a rainfall event. For example at hour 3, 0.6 or 60% of the total rain had fallen. You will need to create a function that allows me to enter a number between 0 and 6, and it must return the total amount of rainfall that has occurred. I must also be able to enter fractional numbers - for example if I enter 4.5 it should return 0.91 by using interpolation (use standard linear interpolation - [login to view URL] )
Project 2.
A common use for trees is the Expression Tree. This is a specific case of a binary tree. When you write an equation, the computer stores the equation in a tree - which stores both the operations and the expression order.
See Attached File
If we traverse the tree using left - first traversal - the first dead end node is 2, then traverse back up to - and down to * and then down again to 3, then up to * and back down to 4 - so the traversal order without intermediate points is
2, 3, 4, *, - 5, +
The logical execution order is
3, 4, * = result
2, result, - = result
result, 5, + = result
or if you were to put it in logical order 2 - 3*4 + 5 , our original equation. For this assignment you will create a binary tree representation of the equation
3*(x + 5*y)
Hint: there are plenty of javascript code examples of creating a binary tree ([login to view URL] )
You will then fill it in and execute by traversing the tree with given values (input by user - you need a GUI to input X and Y), and output a result.
So output should be (if I enter 1,1)
X = 1, Y=1, Output = 18
Project 3
Graph
See attached file