Explain the mechanics of a hash function and how load factors affect the performance of lookup operations.