CS302 TEST 2025
void nChoosek(int index, int k) {
if (k == 0) {
print out vector //base case
}
if (k > n) { //error check
return
}
team.push_back(num[index]);
nchoosek(index + 1, k - 1);
team.pop_back()
nChoosek(index + 1, k);
} - ANSWER what is the basic algorithm for an n choose k recursion?
int top i, j, k;
top = 1;
for(i = 0; i < n; i++) top *= 3; (3^n)
for(i = 0; i < top; i++) {
j = i;
for(k = 0; k < n(length of strings); k++) {
cout << 'character' + j % 2; (size of alph)
j /= 2; (size of alph)
}
cout << endl;
} - ANSWER what is a basic div mod algorithm?
- ANSWER
void powerSet(vector<char> vector) {
void nChoosek(int index, int k) {
if (k == 0) {
print out vector //base case
}
if (k > n) { //error check
return
}
team.push_back(num[index]);
nchoosek(index + 1, k - 1);
team.pop_back()
nChoosek(index + 1, k);
} - ANSWER what is the basic algorithm for an n choose k recursion?
int top i, j, k;
top = 1;
for(i = 0; i < n; i++) top *= 3; (3^n)
for(i = 0; i < top; i++) {
j = i;
for(k = 0; k < n(length of strings); k++) {
cout << 'character' + j % 2; (size of alph)
j /= 2; (size of alph)
}
cout << endl;
} - ANSWER what is a basic div mod algorithm?
- ANSWER
void powerSet(vector<char> vector) {