# HTML and Javascript assignment | Homework | Online project help

We are here to provide *help with HTML programming assignment. *Our team of *expert HTML programming tutors *are available 24*7 to offer *help with HTML programming homework. *Below you will find a series of *Html* projects, this demonstrates the style of work we can do for you.

You should find an example *Html assignment,* that demonstrates the style of the work we are able to do for you.

## Binary Trees

Introduction

Tree (of all sorts) are used throughout *programming.* You should become familiar with the types of trees and you will do a little bit of the use of trees. Trees are covered in Topic – Tree Data Structures

*Assignment*

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.

We will give an example 2 – 3 * 4 + 5

The expression tree for this is;

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 (http://www.nczonline.net/blog/2009/06/09/computer-science-in-javascript-binary-search-tree-part-1/ )

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

Please help me with this *assignment.* It needs to be submitted as a JSFiddle (http://jsfiddle.net/) using HTML/CSS and *Javascript.* Thank you!

## page.html

Enter the values:<br/> X: <input type="text" id="x" /> <br/> Y: <input type="text" id="y" /> <br/> <input type='button' value='Calculate' onclick='calculate();'/> <br/><br/> <span id='output' />

## page.js

window.calculate = function() { var output = document.getElementById('output'); // get the values of x and y var x = document.getElementById('x').value.trim(); var y = document.getElementById('y').value.trim(); // convert to numbers x = parseFloat(x); y = parseFloat(y); if (isNaN(x) || isNaN(y)) { output.innerHTML = "Error: x or y is not a number."; return; } // construct the true for expression // 3 * (x + 5 * y) // leaf nodes var leaf3 = new leaf(3); var leafx = new leaf("x"); var leaf5 = new leaf(5); var leafy = new leaf("y"); // intermediate nodes var mult1 = new node("*", leaf5, leafy); // 5 * y var add1 = new node("+", leafx, mult1); // x + 5 * y var mult2 = new node("*", leaf3, add1); // 3 * (x + 5 * y) // evaluate the tree with the values var values = {}; values["x"] = x; values["y"] = y; var result = mult2.traverse(values); // display the result output.innerHTML = "X = " + x + ", Y = " + y + ", Output = " + result; }; // leaf node for operands function leaf(value) { this.value = value; } // construct a intermediate node for operators function node(symbol, left, right) { this.symbol = symbol; this.left = left; this.right = right; } // traverse the tree leaf.prototype.traverse = function(values) { if (isNaN(this.value)) { // variable return values[this.value]; } // constant return this.value; }; node.prototype.traverse = function(values) { // get the value of left and right children var left = this.left.traverse(values); var right = this.right.traverse(values); // calculate the result var symbol = this.symbol; if (symbol == '+') { return left + right; } if (symbol == "-") { return left - right; } if (symbol == '*') { return left * right; } if (symbol == '/') { return left / right; } // operator not defined return 0; };

We also provide *online HTML programming project help *to our students. Our experts who provide *help with HTML programming homework *are highly skilled. Students from all over the world have availed our *help with HTML programming assignment. Our experts understand the level of complexity and thus provide simple codes that are easy to understand to the students to seek our HTML programming homework help. If your HTML queries are difficult then get the best HTML programming project help from our best experts. We are always available online via live-chat support to provide HTML programming homework help. 100% original HTML programming assignment help is provided. So if you decide that you need HTML programming homework help then I’m sure we can provide a solution.*