## bigoh7

Language/Type: C++ algorithm analysis big-oh
Author: Marty Stepp (on 2016/06/16)

Give a tight bound of the nearest runtime complexity class for each of the following code fragments in Big-Oh notation, in terms of the variable N. In other words, write the code's growth rate as N grows. Write a simple expression that gives only a power of N using a caret `^` character for exponentiation, such as `O(N^2)` to represent O(N2) or `O(log N)` to represent O(log2 N). Do not write an exact calculation of the runtime such as O(2N3 + 4N + 14).

 ```// a) int sum = 0; for (int i = 1; i <= N - 999; i++) { for (int j = 1; j <= 0.0001 * N/2; j++) { sum++; } }``` answer: ```// b) int sum = 0; for (int i = 1; i <= 1000000; i++) { sum++; } int x = 999999; for (int i = 1; i <= x; i++) { for (int j = 1; j <= 999; j++) { sum++; } for (int k = 1; k <= 999; k++) { sum++; } } cout << sum << endl;``` answer: ```// c) Vector vecC; for (int i = 1; i <= N; i++) { vecC.insert(0, i); } Set setC; for (int i = 0; i < vecC.size(); i++) { setC.add(vecC[i]); } cout << "done!" << endl;``` answer: ```// d) Map mapD; for (int i = 1; i <= N; i++) { mapD.put(i, i/2); } Set setD; for (int i = 1; i <= N; i++) { int value = mapD.get(i); setD.add(value); mapD.remove(i); } cout << "done!" << endl;``` answer: ```// e) Vector vecE; for (int i = 1; i <= N; i++) { vecE.add(i); } Stack stackE; while (!vecE.isEmpty()) { stackE.push(vecE[vecE.size() - 1]); vecE.remove(vecE.size() - 1); } cout << "done!" << endl;``` answer: