CSL201: Assignment 2

Due Date : February 24, 2013

Storing hierarchical structure of a company

We want to maintain the list of employees in a company. We will be concerned with two quantities associated with each employee in the company -- name of the employee (you can assume no two employees in the company have the same name), and the level of the employee. The level denotes where the person stands in the hierarchy. Level 1 denotes the highest post in the company (say the CEO), level 2 comes below level 1 and so on. There is only 1 person at level 1, but there can be several employees at level i > 1. Each level i employee works under a level i-1 employee, which is his/her immediate boss. Given an employee A, we can form a sequence of employees A',A'', A''', ... where A works under A', A' works under A'', and so on. We say that each employee in A',A'', A''',... is a boss of A. We would like to implement a suitable tree data-structure so that we can implement the following operations : Write a program which implements such a data-structure. It should display a menu where one can choose between any of the operations mentioned above. Credit will be given to choice of proper data-structures and efficiency. For example, in the second operation above, one should not just search the entire tree to look for the name of the employee S'. Your program should also catch errors, for example if in the first operation above, there is no employee with name S', then it should say it is an error. Use the notions of exceptions in JAVA to implement error checking.