-
-
Notifications
You must be signed in to change notification settings - Fork 26
Implemented Heap Sort Algorithm #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented Heap Sort Algorithm #8
Conversation
There was a problem hiding this 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 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is fine, but it would be better if you could add more test cases! 👍
Thanks, @SatinWukerORIG Sure, I will work on adding more test cases 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added more test cases for the heap_sort module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the cases that you made 👍
Do you think writing the algorithm and test cases inside one file is better? Or is it easier to write in separate files? In other repositories of TheAlgorithms (like Python and Java), we put everything under one file. Fortran is an old and redundant language, do you think which way is more readable?
Thanks 🙂 In a language with verbose syntax like Fortran, combining both algorithm logic and test logic in one file can result in longer files that are harder to navigate. Separating them encourages modularity and clarity, especially when dealing with many test cases or complex algorithms. We can probably use subdirectores to group the relevant files: algorithm, example usage, and test cases, by algorithm name. For instance, we could use a structure like this: In the Java repository they seprate the two logics: Java Repository. In contrast, in the Python repository, combining the two works well because of Python’s concise syntax. Test cases are often embedded directly in the docstrings alongside the algorithm code, as seen in this example from the Python repository. Let’s not forget that Fortran still holds value in fields like scientific computing, high-performance computing, and numerical analysis. Its performance and optimisation capabilities enable it to endure in computationally intensive domains. 👍 |
Description:
This pull request introduces an implementation of the Heap Sort algorithm.
Definition:
O(n log n)time complexity.Implementation Details:
heap_sort.f90: Contains theheap_sort_modulewith:The implementation follows the module structure as outlined in the contribution guidelines.
Example Usage:
example_usage_heap_sort.f90: A test program that demonstrates theheap_sortsubroutine from theheap_sort_module. It sorts a sample array and prints the results.Additional Test Cases:
tests_heap_sort.f90: A test program that includes a variety of test cases to validate the heap_sort implementation.Reference
The Algorithm Design Manual, Latest edition