Question
Quick-Sort using multi-threading USING C++ The program gets a list of integer values specified in an input file named input.txt. Using the recursive threading and
Quick-Sort using multi-threading USING C++
The program gets a list of integer values specified in an input file named input.txt. Using the recursive threading and quick sort technique, the program should sort the input list. The input input.txt consists of several text based lines. The first line indicates size for the list of numbers to be sorted (n). The next n lines contain the input numbers. The output (output.txt) should be the sorted list, each number in a line. To follow the recursive threading method in the quick sort your implementation should meet the following requirements:
- The main function should read input file and fill an integer array. Then it runs QuickSort function as a new thread and passes the input array to that thread. Main function should wait until QuickSort algorithm is finished and then print out the sorted array in the output.
- The QuickSort function is responsible to select a pivot and divide its input array (e.g. arr) to two sub-arrays (e.g. leftArr and rightArr) as defined in quicksort algorithm. It then calls the QuickSort recursively in a new thread for leftArr and/or rightArr as needed. The main requirement of this assignment is that the implementation should enable leftArr and rightArr be sorted concurrently in two different threads.
Input.txt
8
3304
8221
26849
14038
1509
6367
7856
21362
Output.txt
1509
3304
6367
7856
8221
14038
21362
26849
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started