Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 15th International Conference Dexa 2004 Zaragoza Spain August 30 September 3 2004 Proceedings Lncs 3180

Authors: Fernando Galindo ,Makoto Takizawa ,Roland Traunmuller

2004th Edition

3540229361, 978-3540229360

More Books

Students also viewed these Databases questions

Question

Effective Delivery Effective

Answered: 1 week ago