How akashkinkarpandey/multithreaded-merge-sort works
Project Context and Components
• The project implements a multi-threaded merge sort algorithm in C++.
• The main entry point is in src/main.cpp.
• Two sorting implementations are provided in the src/sorting directory: one for parallel execution (parallelMergeSort) and one for a simpler (possibly sequential) merge sort (simpleMergeSort).
• The parallel version employs threading for splitting the workload and merging sorted subarrays.
Identifying Key Components
• Entry Point: main() from src/main.cpp.
• Sorting Module: The sorting logic divided into separate files:
a. parallelMergeSort (both .cpp and .hpp) — handles the multi-threading part.
b. simpleMergeSort (both .cpp and .hpp) — handles a more straightforward merge sort.
• Threading: Illustrate where new threads are created, managed, and joined, especially within the parallel merge sort implementation.
• Data: Show how input data (dataset to be sorted) flows into the sorting functions and how the result is produced.
• Begin at main().
• Clearly split into the choosing of the algorithm (parallel or simple).
• In the parallel branch: Show data partitioning → spawning threads → concurrent sort → merging results.
• In the sequential branch: Show direct recursive sorting.
• End with output of the sorted array.