Skip to content

Latest commit

 

History

History
71 lines (52 loc) · 2.18 KB

README.md

File metadata and controls

71 lines (52 loc) · 2.18 KB

interview_question_1

Interview Question Q1 2015

Submissions

  1. Publicly: Fork this repo and send us a pull request.
  2. Privately: Send us a tar.gz of your solution including your .git folder so we can see your commit history.

Questions

####Programming

This exercise may be done in the candidate's choice of language. Python is preferred but feel free to use Java or C++ if you are stronger in those languages.

You are 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