Skip to content

Conversation

cesar-011
Copy link

Description of Change

Added a hybrid sorting algorithm combining QuickSort, Insertion Sort, and Selection Sort.
Included tests and example usage.
This implementation is for educational purposes and follows the project's style guidelines.

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: "Hybrid of QuickSort, Insertion Sort, and Selection Sort for educational purposes, not optimized for speed."

@cesar-011
Copy link
Author

Copy link
Collaborator

@realstealthninja realstealthninja left a comment

Choose a reason for hiding this comment

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

Try not to use the raw array and instead opt for either std::vector incase you want an array of dynamic length or std::array if the size is known at compile time

Comment on lines +17 to +20
#include <algorithm> // for std::is_sorted
#include <cassert> // for assert
#include <iostream> // for IO
#include <vector> // for vector in test
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
#include <algorithm> // for std::is_sorted
#include <cassert> // for assert
#include <iostream> // for IO
#include <vector> // for vector in test
#include <algorithm> /// for std::is_sorted
#include <cassert> /// for assert
#include <iostream> /// for IO
#include <vector> /// for vector in test

* sorts the left half with insertion sort
* sorts the right half with selection sort
* created for educational purposes not optimized for speed.
* @author Cesar (https://github.com/cesar-011)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* @author Cesar (https://github.com/cesar-011)
* @author [Cesar](https://github.com/cesar-011)

Comment on lines +22 to +24
/**
* @brief swap two elements of an array
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/**
* @brief swap two elements of an array
*/
/**
* @brief swap two elements of an array
* @tparam T
* @param arr
* @param i
* @param j
*/

Comment on lines +32 to +34
/**
* @brief print the array
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/**
* @brief print the array
*/
/**
* @brief print the array
* @tparam T
* @param arr
* @param size
*/

Comment on lines +198 to +207

// An example
int N = 8;
int array[N] = {8, 5, 9, 20, 2, 13, 3, 1};
print_array(array, N);
std::cout << '\n';
sorting::hybrid_quick_insert_select::hybrid_quick_insertion_selection(array,
0, N);
print_array(array, N);
std::cout << '\n';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// An example
int N = 8;
int array[N] = {8, 5, 9, 20, 2, 13, 3, 1};
print_array(array, N);
std::cout << '\n';
sorting::hybrid_quick_insert_select::hybrid_quick_insertion_selection(array,
0, N);
print_array(array, N);
std::cout << '\n';


// Test 3: positive numbers
{
std::vector<int> arr = {1, 2, 3, 4, 5};
Copy link
Collaborator

Choose a reason for hiding this comment

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

for all your tests you use vectors and pass the data, You could've instead designed the functions to work with vectors directly instead

@realstealthninja realstealthninja added the awaiting modification Do not merge until modifications are made label Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting modification Do not merge until modifications are made
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants