Python Data Modeling Interview Questions

Complete the following Django model to illustrate how a manufacturer can make many different types of cars.

Give manufacturer a name, founding date and a country.

Give car a name, cost, engine capacity and color. Assume that the manufacturer makes cars in only {red, green, blue and pink}.

class Manufacturer(models.Model):
    # A car manufacturer

class Car(models.Model):
    # A type of car

Assume that you have access to an employee's email Inbox, and that you can parse the content of their emails, including the email headers.

  1. How can you use this to deduce their first-degree connections?
  2. What kind of heuristics can you come up with to quantify the strength of these first-degree connections?
  3. How can you use this to deduce their second-degree connections?
  4. How can you use this to deduce their third-degree connections?
  1. Describe how you would store a social graph in a relational database.
  2. Describe an efficient algorithm to determine whether or not person X is a 2nd degree connection of person Y.
  3. Describe an efficient algorithm to determine whether or not person X is a 3rd degree connection of person Y.
  4. How can you make #3 very quick. E.g. how does Linked In compute 3rd degree connections quickly?