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 00:00
Suppose you have 9 coins and one of them is heavier than others. other 8 coins weight equally. you are also given a balance. develop and algorithm to determine the heavy coin using only two measurements with the of the balance. clearly write your algorithm in the form of a pseudocode using the similar notation that we have used in the class to represent sorting algorithms
Answers: 1
question
Computers and Technology, 24.06.2019 00:30
Afiling system in which an intermediary source of reference, such as a file card, must be consulted to locate specific files is called a(n) system. a. shelf filing b. direct filing c. indirect filing d. shingling
Answers: 1
question
Computers and Technology, 24.06.2019 23:00
People should never use telepresence when virtually meeting with a group of co-workers. true false
Answers: 1
question
Computers and Technology, 25.06.2019 08:10
Spreadsheet software is more powerful than financial planning software. - true or false
Answers: 2
You know the right answer?
Data abstraction and problem solving with c++ in mythology, the hydra was a monster with many heads....
Questions
question
Mathematics, 05.07.2019 06:50
question
Mathematics, 05.07.2019 06:50
Questions on the website: 13722367