Skip to content

diotsonev91/Hyper-Quick-Sort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

The program implements the Hyper Quick Sort algorithm, which is a parallel sorting algorithm. 
It allows sorting a large array of numbers using multiple threads, which can significantly improve performance on systems with multiple processor cores.
------
Program flow explanation: 
1. It prompts the user to enter the number of threads to use for sorting and the number of elements in the array.
2. The user then enters the elements of the array.
3. The program calls the `hyperQuickSort` function to sort the array.
4. Inside the `hyperQuickSort` function, the array is divided into partitions, and each partition is sorted independently.
5. The function maintains a stack of partitions that need to be sorted. Initially, the entire array is pushed onto the stack.
6. While the stack is not empty, the function processes each partition in a loop.
7. For each partition, it checks if the partition is small enough to be sorted sequentially or if the number of threads is limited to 1. If so, it calls the `quicksort` function to sort the partition.
8. If the partition is large enough and the number of available threads is greater than 1, it performs the parallel sorting.
9. It selects a pivot element and partitions the array into two subarrays based on the pivot.
10. It creates two tasks for the left and right subarrays and pushes them onto the stack.
11. The number of available threads is divided between the left and right subarray tasks, up to the maximum allowed number of threads (`MAX_THREADS`).
12. The function continues processing the next partition from the stack.
13. Once the stack is empty, the entire array has been sorted.
14. Finally, the sorted array is printed to the console.

About

Simple Hyper Quick Sort implementation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages