Multithreading. Someone help for following problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Multithreading. Someone help for following problem

Suppose u have two arrays a1 and a2 , sort a1 (bubble sort) and a2(selection sort) by using threads. Additionally u shud merge these arrays using merge sort on another thread. Threads shud run in parallel

28th Sep 2017, 3:31 PM
shadab gada
1 Answer
0
Why would you even want something like that? That sounds to me like a not well constructed exercise from a teacher. But to answer your "question": Just use a Controller that starts for a1 and a2 threads, maybe you can use Strategy Pattern for implementation of sorting algorithms. After a1 and a2 are sorted, put them together and then sort them via mergesort. I don't see a chance to use all three sorting methods parallel to solve the problem in the way you want it. More efficient would be to parallelize the merge sort.
29th Sep 2017, 10:21 AM
Simon Siegfried Stinglhammer
Simon Siegfried Stinglhammer - avatar