Sorting/Freq arrays

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/4

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 9:25 PM on 6/6/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

5 Terms

1
New cards

Freq Array Counting Pattern

vector<int> freq(101, 0);

for (int i = 0; i < n; i++) {

int x;

cin >> x;

freq[x]++;

}

2
New cards

Ascending sort pattern

sort(v.begin(), v.end());

3
New cards

Descending sort pattern

sort(v.rbegin(), v.rend());

4
New cards

Neighbor Comparison pattern

sort(v.begin(), v.end());

for (int i = 1; i < n; i++) {

if (v[i] == v[i - 1]) {

cout << "duplicate";

}

}

5
New cards

Letter freq pattern

vector<int> freq(26, 0);

for (int i = 0; i < s.size(); i++) {

freq[s[i] - 'a']++;

}