Facebook Interview Question
Research ScientistsCountry: United States
Person is linked to Entities. An entity would be another person, page etc. The feature set would be the reference set of an entity by that person. And a reference would be weighted.
class Reference {
private:
Entity referrer;
Entity referred;
unsigned int weight;
// Responsible for taking actions on Reference
// example weights of a reference will be re-evaluated
class ReferenceCallback {
public:
void readjust(unsigned int deltaWeight);
};
public:
// Resets callback, and reassigns the weight
void reset(unsigned int weight);
// Only reassigns the weight
void reassign(unsigned int weight);
};
class Entity {
private:
string id;
string name;
string description;
};
class Person : public Entity {
public:
unsigned int age;
Friends* friends;
};
class Page {
public:
};
// Responsible for cooking references between two entities
class ReferenceFactory {
public:
// checks if reference is already there, resets the values
Reference& addReference(Entity& referrer, Entity& referred);
private:
// ReferenceCallback is added to readjust after timeout
Timer* timer;
};
class Timer {
public:
void setTimer(ReferenceCallback& referenceCallback, int action);
};
Person is linked to Entities. An entity would be another person, page etc. The feature set would be the reference set of an entity by that person. And a reference would be weighted.
- Anmol March 01, 2017