Ask Question

Consider the following pseudocode. How much time does the code take to execute? Express all answers in terms of the input variable n, using Big-Oh O () notation. void george (int n) {int m = n; while (m > 1) { for (int i = 1; i < m; i++) int S = 1; m = m/2; }}

+4
Answers (1)
  1. 1 February, 18:01
    0
    Time the code takes to execute is O (n²)

    Explanation:

    The code forms an arithmetic series using it two loops.

    n + (n-1) + (n-2) + ... + 2+1

    =n (n+1) / 2

    =O (n²)
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Consider the following pseudocode. How much time does the code take to execute? Express all answers in terms of the input variable n, using ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers