Skip to content

Latest commit

 

History

History
53 lines (42 loc) · 1.72 KB

File metadata and controls

53 lines (42 loc) · 1.72 KB

Given a tree representing a basic mathematical expression, where:

  • The number of children extending from any node is greater than or equal to 2.
  • Each node could either be a mathematical operator or a real number.
  • Each of the leaf nodes should be (no promises :-)) a real number - Hint : Handle error here....
  • The mathematical operators come from the set (-, +, /, *)
  • If a node is a mathematical operator, the operation should be evaluated left-to-right:
  • So, if you have a subtraction node with 1, 2 and 3 you would evaluate as 1 - 2 - 3 = -4. Write a method that calculates the value of such a tree. Write a program that calculates the value of the tree. Assume your code is part of a production grade library, so exceptional cases should be handled accordingly.

NOTE

  • Your implementation should use only standard library modules. Do not use a pre-existing graph library. Write your own tree implementation and traversal methods.

Some tips:

  • Classes, inheritance and encapsulation are your friends
  • Code readability >> subtle performance gains
  • Unit tests

####MySQL Given the following tables :

employees
name
id
salary
age

projects|

| project_id | | project_name |

employee_projects |

| employee_id | | project_id | | time_spent |

Write a select statement returning the following data ordered by project name:

  • project name
  • sum of all salaries of all employees on the project
  • average age of all employees on the project

Bonus Points : What indexes would you add to make your query go faster.

Example result set:

Project Total Avg
Mad Cash App 500000 33
Big Money App 300000 35