subject

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

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:20
Write a pseudocode solution for each of these problems. 1. design a while loop that lets that user enter a number. the number should be multiplied by 10, and the result stored in a variable named product. the loop should iterate as long as product contains a value less than 100. 2. design a do-while loop that asks the user to enter two numbers. the numbers should be added and the sum displayed. the loop should ask the user whether he or she wishes to perform the operation again. if so, the loop should repeat; otherwise it should terminate. 3. design a for loop that displays the following set of numbers: 0, 10, 20, 30, 40, 50 100. 4. design a nested loop that displays 10 rows of # characters. there should be 15 # characters in each row. 5. convert this for loop to a while loop. declare integer count for count = 1 to 50 display count end for 6. find the error in the following pseudocode. declare boolean finished = false declare integer value, cube while not finished display “enter a value to be cubed.” input value; set cube = value ^ 3 display value, “ cubed is “, cube end while
Answers: 2
question
Computers and Technology, 22.06.2019 20:10
Assume that minutes is an int variable whose value is 0 or positive. write an expression whose value is "undercooked" or "soft-boiled" or "medium-boiled" or "hard-boiled" or "overcooked" based on the value of minutes. in particular: if the value of minutes is less than 2 the expression's value is "undercooked"; 2-4 would be a "soft-boiled", 5-7 would be "medium-boiled", 8-11 would be "hard-boiled" and 12 or more would be a "overcooked".
Answers: 1
question
Computers and Technology, 23.06.2019 01:30
In deadlock avoidance using banker’s algorithm, what would be the consequence(s) of: (i) a process declaring its maximum need as maximum possible for each resource. in other words, if a resource a has 5 instances, then each process declares its maximum need as 5. (ii) a process declaring its minimum needs as maximum needs. for example, a process may need 2-5 instances of resource a. but it declares its maximum need as 2.
Answers: 3
question
Computers and Technology, 23.06.2019 07:00
Why were most movies from the late 1890s until the early 1930s only filmed in black and white? there were only a few people who could afford the technology to produce color motion pictures back then. audiences did not want color motion pictures until later. the film used to make color motion pictures often overheated, which was a safety hazard, so it was generally not allowed. color films had to be hand-colored, frame by frame.
Answers: 3
You know the right answer?
In this project, you will develop a multithreaded program to perform sorting that works as follows:...
Questions
question
Mathematics, 08.09.2021 06:00
question
Mathematics, 08.09.2021 06:00
question
English, 08.09.2021 06:00
question
Mathematics, 08.09.2021 06:00
question
Mathematics, 08.09.2021 06:00
question
Mathematics, 08.09.2021 06:00
question
Mathematics, 08.09.2021 06:00
question
Mathematics, 08.09.2021 06:00
question
Mathematics, 08.09.2021 06:00