Skip to content

Commit

Permalink
Update cycle_sort.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Swastyy committed Jul 12, 2021
1 parent 92334d8 commit 6a57901
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sorting/cycle_sort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ namespace cycle_sort {
template <typename T>
std::vector<T> cycleSort(const std::vector<T> &in_arr) {
std::vector<T> arr(in_arr);
for (size_t cycle_start = 0; cycle_start <= arr.size() - 1; cycle_start++) {
for (int cycle_start = 0; cycle_start <= arr.size() - 1; cycle_start++) {
// initialize item
T item = arr[cycle_start];

// Count the number of elements smaller than item, this number is the
// correct index of item.
int pos = cycle_start;
for (size_t i = cycle_start + 1; i < arr.size(); i++) {
for (int i = cycle_start + 1; i < arr.size(); i++) {
if (arr[i] < item) {
pos++;
}
Expand Down

0 comments on commit 6a57901

Please sign in to comment.