[prev] 64 [next]

Mergesort Variation

Above methods require temporary array
  • provides a useful abstraction (merge(a,lo,mid,hi))
  • but requires malloc()/free() for each merge
  • and copying data to/from temporary array
Alternative approach
  • pass two arrays around: source and destination
  • switch array roles at each recursive call
  • but still requires one malloc()/free()