Exercise: Merge Sort

Let's dive into concurrent programming by implementing the merge sort concurrently.

In this exercise, you are required to write a concurrent solution to the Merge Sort problem using goroutines and channels.

The gist of the Merge Sort Algorithm can be found below :

func MergeSort(data [] int) [] int {
  if len(data) <= 1 {
    return data
  }

  mid := len(data)/2
  left := MergeSort(data[:mid])
  right := MergeSort(data[mid:])
  return Merge(left,right)
}

Get hands-on with 1400+ tech skills courses.