input: Write a python function to implement the genetic algorithm including the missing `crossover`, `mutation`, and `getCost` functions.
  assert geneticAlgorithm([[0, 1, 1, 0], [1, 0, 0, 1], [1, 1, 0, 0]], 10) is not None
  assert geneticAlgorithm([[0, 0, 1, 1], [1, 1, 1, 0], [0, 0, 0, 1]], 5) is not None
  assert geneticAlgorithm([[1, 0, 1, 1], [0, 1, 0, 0], [1, 1, 1, 1]], 20) is not None
output: import random
  
  def crossover(parent1, parent2):
      crossover_point = random.randint(1, len(parent1) - 1)
      child = parent1[:crossover_point] + parent2[crossover_point:]
      return child
  
  def mutation(child, mutation_rate=0.01):
      for i in range(len(child)):
          if random.random() < mutation_rate:
              child[i] = 1 if child[i] == 0 else 0
      return child
  
  def getCost(individual):
      return sum(individual)
  
  def geneticAlgorithm(population, generations):
      for generation in range(generations):
          # Selection
          population = sorted(population, key=getCost, reverse=True)
          
          # Crossover and Mutation
          new_population = []
          while len(new_population) < len(population):
              parent1, parent2 = random.sample(population[:len(population)//2], 2)
              child = crossover(parent1, parent2)
              child = mutation(child)
              new_population.append(child)
          
          population = new_population
      
      return population[0]