Merge Sort Report
Merge Sort Report
Submitted by
Rupprashik Anand Khare (BE_A_54)
In partial fulfillment of
BACHELOR OF ENGINEERING
In
Computer Engineering
Savitribai Phule Pune University, Pune
INTRODUCTION
Merge Sort is a popular sorting algorithm based on the divide-and-conquer approach. It
recursively splits an array into two halves, sorts each half, and then merges the two sorted
halves to get the final sorted array. Multi-threaded Merge Sort is an optimized variation
that uses parallel processing by assigning the sorting of sub-arrays to multiple threads,
aiming to reduce execution time on modern multi-core processors. This project compares
the performance of the standard Merge Sort and the Multi-threaded Merge Sort to analyze
the benefits of parallelism in sorting algorithms.
OBJECTIVE
To implement and analyze the performance of both Merge Sort and Multi-threaded Merge
Sort for sorting an array of integers.
H/W AND S/W REQUIREMENTS
Hardware Requirements:
- Processor: Core i5 or higher
- RAM: 4GB or higher
- Storage: 500 GB HDD
Software Requirements:
- Operating System: Windows 10 / Linux
- Programming Language: Python 3.7+
- Required Libraries: threading, time
THEORY CONCEPTS
Merge Sort is a recursive sorting algorithm that splits the array into two halves,
recursively sorts them, and then merges the sorted halves. The algorithm has a time
complexity of O(n log n), making it efficient for large datasets. However, it requires
additional space for merging, with a space complexity of O(n).
Multi-threaded Merge Sort improves on this by utilizing multiple CPU cores. The array is
divided into two sub-arrays, which are sorted concurrently in separate threads, reducing
the total sorting time. Despite the same theoretical time complexity (O(n log n)), multi-
threading can significantly improve performance on large arrays by paralyzing the sorting
process.
ALGORITHM
1. Standard Merge Sort:
1.1. Split the array into two halves.
1.2. Recursively sort each half.
1.3. Merge the two sorted halves.
1.4. Return the sorted array.
2. Multi-threaded Merge Sort:
2.1. Split the array into two halves.
2.2. Create two threads: one for each half.
2.3. Recursively sort both halves in parallel.
2.4. Merge the sorted halves after both threads complete.
2.5. Return the sorted array.
ADVANTAGES OF MULTITHREADED MERGE SORT
- Efficient for large arrays, particularly on multi-core processors.
- Exploits parallelism to reduce execution time.
- Same theoretical time complexity as standard Merge Sort but faster in practice for large
datasets.
LIMITATIONS OF MULTITHREADED MERGE SORT
- Overhead of thread management can negate benefits for small datasets.
- Threading limits may affect performance depending on the system’s core count.
CONCLUSION
The project successfully implemented and compared the Merge Sort and Multi-threaded
Merge Sort algorithms. The multi-threaded version showed noticeable performance
improvements for larger datasets due to parallel processing. This demonstrates the
potential of multi-threading for optimizing sorting algorithms on modern multi-core
processors.