subject

Data abstraction and problem solving with c++ in mythology, the hydra was a monster with many heads. every time the hero chopped off a head, two smaller heads would grow in its place. fortunately for the hero, if the head was small enough, he could chop it off with out two more growing in its place. to kill the hydra, all our hero needed to do was to chop off all the heads. write a program that simulates the hydra. instead of heads, we will use strings. a bag of strings, then, represents the hydra. every time you remove a string from the bag, delete the fi rst letter of the string and put two copies of the remaining string back into the bag. for example, if you remove hydra, you add two copies of ydra to the bag. if you remove a one-letter word, you add nothing to the bag. to begin, read one word from the keyboard and place it into an empty bag. the hydra dies when the bag becomes empty. using big o notation, predict the time requirement for this algorithm in terms of the number n of charac ters in the initial string. then time the actual execution of the program for various values of n and plot its per formance as a function of n.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 01:10
Are special combinations of keys that tell a computer to perform a command. keypads multi-keys combinations shortcuts
Answers: 1
question
Computers and Technology, 23.06.2019 07:30
Write a program that inserts the digits of an integer into an array in originalorderfollowed by reverse order. first, promptthe user to enter a positive integer(> 0). determine the number of digits of the integer. create a dynamically allocated integer arrayof a size twice the number of digits.now insert the digits in original order which will occupy half of the array. then, insert the digits in reverse order.finally, output thedigits in thearray.use at least two functions to organize your program.
Answers: 3
question
Computers and Technology, 23.06.2019 18:00
What can a word user do with the customize ribbon dialog box? check all that apply. minimize the ribbon add a new tab to the ribbon remove a group from a tab add a group to a tab choose which styles appear choose which fonts appear choose tools to appear in a group
Answers: 1
question
Computers and Technology, 23.06.2019 21:00
Which task uses a simple parameter?
Answers: 1
You know the right answer?
Data abstraction and problem solving with c++ in mythology, the hydra was a monster with many heads....
Questions
question
Health, 31.03.2021 01:00
question
Mathematics, 31.03.2021 01:00
question
Mathematics, 31.03.2021 01:00
Questions on the website: 13722363