Question
(a) Give an exact formula (as a function of n) for the number of hellos printed by Algorithm PRINTHELLOS below. First express it using the
(a) Give an exact formula (as a function of n) for the number of hellos printed by Algorithm PRINTHELLOS below. First express it using the summation notation , and then derive a closed-form expression. Show your work. Note: To derive a closed-form solution you will need a formula for the sum of squares of consecutive integers.
(b) Give the asymptotic value of the number of hellos (using the Theta-notation). Include a brief justification.
Algorithm PRINTHELLOS (n : integer)
for j 1 to 2n + 1 do
for k 1 to j 2 do print(hello)
for j 1 to n 2 do
for k 1 to j do print(hello hello)
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