In: Computer Science
Write a pseudo code for an O (n7log3n) algorithm. Please write in C++.
#include <iostream>
using namespace std;
int main() {
int n = 10;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
for (int k = 0; k < n; ++k) {
for (int l = 0; l < n; ++l) {
for (int m = 0; m < n; ++m) {
for (int a = 0; a < n; ++a) {
for (int b = 0; b < n; ++b) {
/*
* Time complexity of this while loop is log3(n)
* And there are 7 nested for loop
* so, total time complexity is n*n*n*n*n*n*n*log3(n)
* = O(n^7 log3(n))
*/
int c = 0;
while (c < n) {
c *= 3;
}
}
}
}
}
}
}
}
return 0;
}