-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3_sum_of_nums.cpp
More file actions
44 lines (40 loc) · 1.01 KB
/
3_sum_of_nums.cpp
File metadata and controls
44 lines (40 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<bits/stdc++.h>
using namespace std;
using namespace std::chrono;
int get_sum(vector<int> &arr , int i)
{
if(i==arr.size())
return 0;
return arr[i] + get_sum(arr,i+1);
}
void input_generator(vector<pair<int,int>> &store)
{
for(int i=1000 ; i<=1e4; i+=300)
{
vector<int> arr(i);
for(int j=1 ; j<=i ;j++)
arr[j-1] = j;
int t=0;
for(int m=1 ; m<=10 ; m++)
{
auto start = high_resolution_clock::now();
get_sum(arr,0);
auto stop = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(stop - start);
t+=duration.count() ;
}
t= t/10;
store.push_back({t,i});
}
}
int main()
{
vector<pair<int,int>> store;
input_generator(store);
cout << "Time " << "\t" << "Number of inputs " << endl << endl;
for(auto i : store)
{
cout << i.first << "\t" << i.second << endl;
}
return 0;
}