Google Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: In-Person
There are two classes in this problem:
1) Species
2) Animal
Species should use Tree Structure
class Species {
//attributes
Species *belongs_to;
string type_name;
std::vector<Species *> sub_types;
//function
void behavior() {***};
};
Animal should belongs to one species.
Animal {
//attributes
Species the_type;
};
By arranging them in a tree order we can easily form the model and if necessary new species can be added.
- gopinath January 10, 2014