i need parallel program that can sort 500,1000,1500,2000 numbes in bubble sort,selection sort,insertion sort and merge sort.

You need to create threads in order to do parallel program. How to do that depends on the operating system you are using, or threading extensions of c++11 standards. A third option is to use boost threading library. If you are using a pretty new compiler, such as most recent version of g++ it will support c++11 threading.

I think that you will have a bit of problems because of all the algorithms you cited, only "merge-sort" is parallelizable, AFAIK. In any case, parallelizing an algorithm is very tricky business, especially if your aim is to compare the performance. In fact, the overhead coming from synchronization is generally so significant, even in really good parallel sort algorithms, that you won't be able to beat a single-threaded lean implementation like std::sort for data sets smaller than 100 thousand elements or more. That's how significant the overhead is.

I would guess that you must have misunderstood the question because I doubt very much that anyone would ask you to write a parallel bubble sort algorithm. So, I'm not sure what that "parallel" word really refers to.

In any case, we won't do your homework for you. You have to show that you are making efforts to solve this problem by yourself and ask us questions about specific problems that you are encountering with your code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.