Please use the following multiple choice answers:
p1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <map>
using namespace std;
int main()
{
int i, n;
map <int, int> m;
cin >> n;
for (i = 0; i < n; i++) {
m[i] = n;
}
return 0;
}
p2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <map>
using namespace std;
int main()
{
int i, n;
map <int, int> m;
cin >> n;
for (i = 0; i < n; i++) {
m[n] = i;
}
return 0;
}
p3.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <map>
using namespace std;
int main()
{
int i, n;
map <int, int> m;
map <int, int>::iterator mit;
cin >> n;
for (i = 0; i < n; i++) {
mit = m.find(n);
if (mit != m.end()) {
m.erase(mit);
} else {
m.insert(make_pair(n,i));
}
}
return 0;
}
Question 1: What is the big-O running time of p1.cpp?
Question 2: What is the big-O running time of p2.cpp?
Question 3: What is the big-O running time of p3.cpp?
Question 4: When we compile and run p1.cpp, how many bytes does the program consume while it’s running?
PDF Download, 2022 January Class Stats, 2022 April Class Stats, 2023 Class Stats, 2023 ChatGPT Answer