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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!