Back to the 2022 paper

Module 1: Introduction and Complexity Analysis

20227m

Write time function and calculate the time complexity, space complexity and number of function calls of the following pseudocode using substitution method:

rec(n) {
    if (n <= 1) return(1);
    else {
        rec(n / 2);
        for (i = 1; i <= n; i++)
            printf("algorithm");
    }
}

Similar questions