Question d’entretien chez Booking.com

In SQL Server, what’s the difference between a merge join and a hash join? In what situations would the optimizer pick one over the other—considering things like sorted inputs, memory use, and data volume?