Computers and Technology

In this project, you will develop a multithreaded program to perform sorting that works as follows: a
list of integers is divided into two smaller sublists. two separate threads (which we will term sorting
threads) sort each sublist using the selection sorting algorithm. the two sublists are then merged by a
third thread—a merging thread —which merges the two sublists into a single sorted list.

graphically, this program is structured according to the following figure:
original list (7, 12, 19, 3, 18, 4, 2, 6, 15, 8)
sorting thread0 (3, 7, 12, 18, 19) sorting thread1(2, 4, 6, 8, 15)
merging thread(2, 3, 4, 6, 7, 8, 12, 15, 18, 19)

this programming project will require passing parameters to each of the sorting threads. in particular,
it will be necessary to identify the starting index from which each thread is to begin sorting. the
parent thread will output the sorted array once all sorting threads have exited.

data structure
because data are shared cross all threads, perhaps the easiest way to set up the data is to create an
array. each sorting thread will work on one half of this array. a second array of the same size as the
unsorted integer array will also be established. the merging thread will then merge the two sublists
into this second array.

program structure
the program consists of the following classes:
1) mergesort: main method performs the following tasks:
a. prompt user to enter the data (a list of integers).
b. create two threads and use them to sort the first half and the second half of the list.
c. create a thread to merge the two sublists into a single list.
d. display the sorted list.
2) sortthread: implements run method. sort the elements in an array with index range
start, end using the selection sort algorithm
3) mergethread: implements run method. merge a list whose first half and second half are
sorted into a new sorted list.

the following is a sample run of the program:
enter the size of the sequence: 11
enter the numbers to be sorted : 9 2 8 11 4 67 34 4 19 10 23
the sorted list is: 2 4 4 8 9 10 11 19 23 34 67

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 09:40, cutybrain6054
Sarah is having a hard time finding a template for her advertising business that she may be able to use at a later date and also make it available to her colleagues
Answers: 1
image
Computers and Technology, 23.06.2019 12:40, Emilyvite6251
According to the video what are some tasks petroleum engineers perform check all that apply
Answers: 2
image
Computers and Technology, 24.06.2019 05:30, MOONCHILDSUGA
If you combine two cells into one, what action are you performing? a.  adding a new row or column      b.  splitting the cells      c.  removing a new row or column      d.  merging the cells
Answers: 2
image
Computers and Technology, 24.06.2019 06:30, meganwintergirl
Ineed to know the anwser to all these questions
Answers: 2
Do you know the correct answer?
In this project, you will develop a multithreaded program to perform sorting that works as follows:...

Questions in other subjects:

Konu
Mathematics, 11.02.2021 01:50