Publicis Sapient Interview Question

When to use composite and factory design patterns?