Skip to content

Conversation

@Ramy-Badr-Ahmed
Copy link
Member

@Ramy-Badr-Ahmed Ramy-Badr-Ahmed commented Sep 10, 2024

Description:

This pull request introduces an implementation of the Quick Sort algorithm .

Definition:

  • Quick Sort is a highly efficient sorting algorithm that uses the divide-and-conquer approach.
  • The Algorithm selects a pivot element and partitions the array into two halves: elements less than the pivot and elements greater than the pivot.
  • It is competitive with algorithms like Merge Sort Implemented Merge Sort Algorithm #7 and Heap Sort Implemented Heap Sort Algorithm #8 .
  • It has an average time complexity of O(n log n), though it can degrade to O(n²) in the worst case (depending on the pivot choice).
  • Compared to Gnome Sort Implemented Gnome Sort Algorithm #9 , which has a time complexity of O(n²), Quick Sort is far more efficient for large datasets.

Implementation Details:

quick_sort.f90: Contains the quick_sort_module with:

quick_sort: A recursive subroutine that sorts the input array using the Quick Sort algorithm.
partition: A helper function that partitions the array based on a pivot element.
swap: A helper subroutine that swaps two elements in the array.

The implementation follows the module structure as outlined in the contribution guidelines.

Example Usage:

example_usage_quick_sort.f90: A test program that demonstrates the quick_sort subroutine from the quick_sort_module. It sorts a sample array and prints the results.

Additional Test Cases:

tests_quick_sort.f90: A test program that includes a variety of test cases to validate the quick_sort implementation.


Reference

The Algorithm Design Manual, Latest edition

Copy link
Member Author

@Ramy-Badr-Ahmed Ramy-Badr-Ahmed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @SatinWukerORIG ,
Looking forward to your review 🙂

Copy link
Member Author

@Ramy-Badr-Ahmed Ramy-Badr-Ahmed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added more test cases for the quick_sort module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants