Skip to content

Commit

Permalink
[Update] Some fixes on comments and brace additions
Browse files Browse the repository at this point in the history
  • Loading branch information
spirosmaggioros committed Dec 26, 2024
1 parent c73045b commit 4f934b5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/algorithms/searching/interpolation_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ int64_t interpolation_search(Iterator begin, Iterator end, T key) {
auto offset = static_cast<int>(static_cast<double>(size - 1) * (key - *it_begin) / (*it_end - *it_begin));
std::advance(guess, offset);
}
if (*guess == key)
return std::distance(begin, guess);
if (*guess == key) {
return std::distance(begin, guess);
}

if (*guess > key) {
it_end = guess-1;
Expand Down
5 changes: 3 additions & 2 deletions src/algorithms/searching/split_K_max.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ namespace helpers {
}

/**
* @brief minimum max sub sum function. Finds the minimum maximum subarrays(=K) sum
* and returns the maximum of them
* @brief minimum max sub sum function. Finds the maximum sum of each K subarrays
* and returns the minimum of them. Basically, answers the question: "What is the best way
* of splitting a field to your K sons - without changing the order - so that you are as fair as possible"
*
* @param v: vector<int> the passed array
* @param K: the total subarrays
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/sorting/minimum_swaps.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**
* @brief minimum swaps function.
* @details computes the minimum swaps to make array 2 arrays equal
* @details computes the minimum swaps to make array two arrays equal
* @param a: vector<int>
* @param b: vector<int>
* @return int: the minimum number of swaps to make array a equal to array b
Expand Down
5 changes: 3 additions & 2 deletions src/algorithms/sorting/quick_sort.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ template <typename Iter> Iter median_of_three(Iter a, Iter b, Iter c) {
*/
template <typename Iter> void quick_sort(Iter begin, Iter end) {
auto distance = std::distance(begin, end);
if (distance <= 1)
return;
if (distance <= 1) {
return;
}

// choose the pivot as median of first, middle and last element
Iter mid = begin + distance / 2;
Expand Down
5 changes: 3 additions & 2 deletions src/classes/hash_table/hash_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ template <typename KeyType, typename ValueType> class hash_table {

Iterator begin() {
auto startIterator = bucketList.begin();
while (startIterator != bucketList.end() && startIterator->second.empty())
startIterator++;
while (startIterator != bucketList.end() && startIterator->second.empty()) {
startIterator++;
}
return Iterator(startIterator, bucketList.end());
}

Expand Down

0 comments on commit 4f934b5

Please sign in to comment.