Question
variables m and n are assumed to have been declared as integers. Also assume that when the code fragment begins execution, the variable n has
variables m and n are assumed to have been declared as integers. Also assume that when the code fragment begins execution, the variable n has a positive value (i.e., is 1 or greater), and the function push is a basic operation. Stack
Let T(n) denote the execution time that will be observed when this code fragment is executed. Which of the following statements best describes T(n) ? Explain why. (a) T(n) = An + B for some constants A and B . (b) A1n + B1 T(n) A2n + B2 for some constants A1 , B1 , A2 , and B2 . (c) T(n) = An2 + Bn + C for some constants A, B, and C .
the variables m and n are assumed to have been declared as integers, and the array a has at least n cells that have been given various integer values. for (m = n1; m >= 0; m) if (a[m] < 0) // If a[m] is negative, then change a[m] *= (1); // its sign by multiplying it by 1 . Let T(n) denote the execution time that will be observed when this code fragment is executed. Which of the following statements best describes T(n) ? Explain why. (a) T(n) = An + B for some constants A and B . (b) A1n + B1 T(n) A2n + B2 for some constants A1 , B1 , A2 , and B2 . (c) T(n) = An2 + Bn + C for some constants A, B, and C .
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started