Skip to content

Commit 6aeb6c0

Browse files
committed
Translated comments in CountingSort
1 parent c0ff148 commit 6aeb6c0

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/cpp/CountingSort.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ vector<int> counting_sort(vector<int>& nums) {
99

1010
// nums = {5, 0, 1, 2, 3, 5, 3, 0, 9, 4}
1111
// max = 9
12-
// vector nums contem elementos entre [0 .. max]
12+
// The vector contains numbers between [0 .. max]
1313
auto max = *max_element(nums.begin(), nums.end());
1414

1515

16-
// cria um vector com max + 1 posicoes para contar ocorrências de cada elemento
17-
// 0 1 2 3 4 5 6 7 8 9 -> elementos possiveis de ocorrer no vector nums
18-
//counting = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
16+
// Creates a vector with max + 1 positions to count occurrences of each element
17+
// 0 1 2 3 4 5 6 7 8 9 -> possible elements to occur in the vector nums
18+
// Counting = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
1919
vector<int> counting(max+1);
2020

2121

22-
// conta ocorrencias de cada elemento
22+
// Counts occurrences of each element
2323
// nums = {5, 0, 1, 2, 3, 5, 3, 0, 9, 4}
2424
//
2525
// 0 1 2 3 4 5 6 7 8 9
@@ -30,8 +30,8 @@ vector<int> counting_sort(vector<int>& nums) {
3030
}
3131

3232

33-
// agora, counting = {2, 3, 4, 6, 7, 9, 9, 9, 9, 10}
34-
// sera utilizado para determinar as posicoes dos elementos no vector ordenado
33+
// Now, counting = {2, 3, 4, 6, 7, 9, 9, 9, 9, 10}
34+
// It will be used to determine the positions of the elements in the ordered vector
3535
for (size_t i = 1; i < counting.size(); i++) {
3636

3737
counting[i] += counting[i-1];
@@ -41,29 +41,29 @@ vector<int> counting_sort(vector<int>& nums) {
4141

4242
/*
4343
44-
O proximo loop coloca os numeros em suas devidas posicoes no vetor ordenado
45-
i = itera pelos elementos de nums
46-
counting[i] -1 é a posicao que o elemento i devee assumir no vetor ordenado
44+
The next loop places the numbers in their proper positions in the ordered vector
45+
i = iterates through the elements of nums
46+
counting[i] -1 is the position that element i must assume in the ordered vector
4747
48-
Os 3 primeiros passos seriam:
48+
The first 3 steps would be:
4949
5050
nums = {5, 0, 1, 2, 3, 5, 3, 0, 9, 4}
5151
counting = {2, 3, 4, 6, 7, 9, 9, 9, 9, 10}
5252
sorted = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
5353
54-
passo 1:
54+
Step 1:
5555
i = 5
5656
counting[i] => counting[5] => 9
5757
sorted[9 - 1] => sorted[8] = i => sorted[8] = 5
5858
sorted = {0, 0, 0, 0, 0, 0, 0, 0, 5, 0}
5959
60-
passo 2:
60+
Step 2:
6161
i = 0
6262
counting[i] => counting[0] => 2
6363
sorted[2 - 1] => sorted[1] = i => sorted[1] = 0
6464
sorted = {0, 0, 0, 0, 0, 0, 0, 0, 5, 0}
6565
66-
passo 3:
66+
Step 3:
6767
i = 1
6868
counting[i] => counting[1] => 3
6969
sorted[3 - 1] => sorted[2] = i => sorted[2] = 1

0 commit comments

Comments
 (0)