Analysis of Algorithms: Assignment 1
1) Given the following code, trace it on a sample data, then specify its functionality and
its time complexity in terms of Big-O notation.
for (int i = 1; i <= 2 * n; i++)
for (int j = 1; j <= n; j++)
cout << 2 * i + j << “ “;
cout << endl;
2) Given the following algorithm, specify its type, its functionality. Then, trace it on a
sample input, and compute its time complexity.