linker | compiler | ls | cd | gdb |
g++ | vector | array | struct | class |
private | protected | public | substr | find |
make | makefile | argc | argv | vi |
h(key) = key % 13
Separate Chaining | Quadratic Probing | |
---|---|---|
0 | ||
1 | ||
2 | ||
3 | ||
4 | ||
5 | ||
6 | ||
7 | ||
8 | ||
9 | ||
10 | ||
11 | ||
12 |
key | quadratic probing |
---|---|
32 | |
49 | |
19 | |
52 | |
58 | |
15 |
string name = "VJ"; unsigned char h = 41; int i; for (i = 0; i < name.size(); i++) { h = (h << 2) ^ name[i]; } |
where 'V' = 0x56 and 'J' = 0x4a What is the hexadecimal value of h after each iteration of the above loop? Show your work if you want partial credit.
iteration | h |
---|---|
0 | |
1 |
If you cannot figure out the hexadecimal value, you can give the base-10 value for a 2 point deduction.
(a) | (b) |
void insert(int num, vector<int> &data) { int i; data.resize(data.size()+1); for (i = 0; i < data.size()-1; i++) data[i+1] = data[i]; data[0] = num; } |
void insert(int num, vector<int> &data) { int i; data.resize(data.size()+1); for (i = data.size()-2; i >= 0; i--) data[i+1] = data[i]; data[0] = num; } |
---|
(a) | (b) |
vector<string> readStrings() { string name; vector<string> names; while (cin >> name) { names.push_back(name); } return names; } |
void readStrings(vector<string> &names) { string name; while (cin >> name) { names.push_back(name); } } |
---|
hh:mm:ssEach of the three fields should be 2 spaces wide. The minutes and seconds should be padded with a 0 if they are single digits, but hours should not be. For example "3:06:05".
int hours, minutes, seconds;