Answered step by step
Verified Expert Solution
Question
1 Approved Answer
EXERCISE 12. The United States of Algorithmica (for short: USA) comprise 2 states, but the exact value of n is unknown. The flag of USA
EXERCISE 12. The United States of Algorithmica (for short: USA) comprise 2" states, but the exact value of n is unknown. The flag of USA is blue; it has n +1 rows, each (except the first one) with 2n-1 red stars and 2n-1 white stars. The first row contains just a sequence of 2 red stars. The second row starts with 2n-1 red stars followed by 2n-1 white stars. The third row starts with a sequence of 2n2 red stars followed by 2n-2 white stars, again 2n2 red stars, and finally 2n-2 white stars. This continues in the same way, so the last row contains an alternating sequence of red and white stars starting with a red one. Once there was a big argument between the states how to program the flag, which led (temporarily) to a separation of the country into the Iterative States of Algorithmica (for short: ISA) and the Recursive States of Algorithmica (for short: RSA). (i) Specify a sequential algorithm used in ISA that takes n as input and produces the flag of USA. (ii) Specify a recursive algorithm used in RSA that takes n as input and produces the flag of USA. (iii) For both algorithms determine the order of magnitude for the number of steps required to produce the flag
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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