The function left_join performs a left join on two hash tables hashTable1 and hashTable2. It initializes an empty list output. For each key in hashTable1, it checks if the key exists in hashTable2. If the key exists in both hash tables, it appends [key, hashTable1.get(key), hashTable2.get(key)] to output. If the key exists only in hashTable1, it appends [key, hashTable1.get(key), None] to output. Finally, it returns the output list.
Time Complexity: O(n), where ānā is the number of keys in hashTable1. Space Complexity: O(n) in the worst case due to the output list storing the left join results.
def left_join(hashTable1,hashTable2):
'''
A method to perform a left join on two hashtables
args: HashTable1,HashTable2
'''
output=[]
keyss= hashTable1.keyss()
for key in keyss:
if hashTable2.has(key):
output.append([key,hashTable1.get(key),hashTable2.get(key)])
else:
output.append([key,hashTable1.get(key),None])
return output