Skip to content
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

Update bitonic_sort.cpp #2739

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

khushbooshakya
Copy link

@khushbooshakya khushbooshakya commented Sep 24, 2024

Updated the bitonic sort code in simplest form

Description of Change

Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes:

Updated the bitonic sort code in simplest form
@khushbooshakya
Copy link
Author

Implement Bitonic Sort Algorithm in C++

  • Added compAndSwap() to compare and swap elements based on sorting direction.
  • Added bitonicMerge() to merge bitonic sequences into the correct order.
  • Added bitonicSort() to recursively sort and merge the array.
  • Main function demonstrates sorting an array in ascending order.

#include <algorithm>
#include <iostream>
Purpose: Compares two elements and swaps them if needed.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

please use the proper comment format in the contribution guidelines

#include <iostream> // For input/output operations

// Function to compare and swap two elements based on sorting direction.
// dir = 1 means ascending order, dir = 0 means descending order.
void compAndSwap(int a[], int i, int j, int dir) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

please document functions using the format in the contribution guidelines

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