From the course: Complete Guide to Parallel and Concurrent Programming with C++
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Challenge: Merge sort - C++ Tutorial
From the course: Complete Guide to Parallel and Concurrent Programming with C++
Challenge: Merge sort
(upbeat music) - [Instructor] For our second challenge problem, your goal will be to design and build a parallel version of a classic merge sort algorithm to sort an array of random integers. Merge sort is a well-known divide and conquer algorithm for sorting the elements in an array. During the divide phase, it recursively splits the input array into two halves, referred to as the left half and the right half. From there, the merge phase repeatedly merges those sorted sub arrays to produce new, larger sorted sub arrays, and it continues until there's only one sub array remaining, which is the final sorted result. To give you a starting point for this challenge, we've already implemented a sequential version of a merge sort algorithm in this example program. The sequential_merge_sort function on line 10 takes in a pointer to the array of integers that we want to be sorted along with the arguments for the first and last indices of the section of the array to sort, called left and…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.