Amazon.com Interview Question
1,566 Interview Reviews |
Back to all Amazon.com Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Kindle Fire at Amazon.com:
Create a data structure to keep track of hierarchy of employees, wages etc. Some are managers, VPs etc. They need to be interlinked such that a manager is linked to all workers under him etc. A VP has different managers under him. Need way to be able to traverse this data structure and have different pay grades etc.
Helpful Question?
Yes |
No
Inappropriate?
Answers & Comments (2)
struct employee {
struct employee *supervisor;
struct employee *team_members[MAX_TEAM];
int pay;
char *fname;
char *lname;
};
struct employee *root;
struct employee *traverse_employees(struct employee *root, char *fname, char *lname){
struct employee *tmp, *ret;
int i;
if (root == NULL){
fprint("No such a employee\n");
return NULL;
}
else if (root->fname == fname && root->lname == lname)
fprint("Employee %s %s is found and the pay is %d", fname, lname, root->pay);
return root;
else {
for (i = 0; i < MAX_TEAM; i++) {
tmp = root->team_members[i];
if (tmp != NULL){
ret = traverse_employee(tmp, fname, lname);
if ( ret !=NULL ){
fprint("Employee %s %s is found and the pay is %d", fname, lname, ret->pay);
return ret;
}
}
}
}
return NULL;
}
Helpful Answer?
Yes |
No
Inappropriate?
To comment on this
question,
Sign In with Facebook or
Sign Up



0 of 0 people found this helpful
by Interview Candidate: