Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4. (10 points) Fill in the blanks below with complexity results stated in terms of n Assume print produces one line of output (a) Fragmernt
4. (10 points) Fill in the blanks below with complexity results stated in terms of n Assume print produces one line of output (a) Fragmernt for i-n downto 1 print(n + " bottles of beer on the wall, "+ n + " bottles of beer") print("you take one down, pass it around, ") print((n-1) + " bottles of beer on the wall") end The above fragment prints (b) Fragment for i-1 to n print("On the + i + "th day of Festivus my true love gave to me") for j-i downto 1 print(i + " nifty "+i+ "-things") end end The above fragment prints e lines (c) Fragment for i-1 to n int[] array = new int [5]; end Worst-case, the above fragment takes e time (d) Fragment for i-1 to n int[] array = new int [i]; end Worst-case, the above fragment takes e time. (e) Fragment while (i > 0) print("Zeno is almost there") i-i/2 // integer division and result end Worst-case, the above fragment prints (--) lines
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