1 create a recursive factorial program that


1. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!. For example, if the input is 4, the output could be:

4! = 4! 

= 4 * 3!

= 4 * 3 * 2!

= 4 * 3 *2 * 1!

= 4 * 3 * 2 * 1 * 0!


2. Explain the relationship between dynamic storage allocation and recursion.


3. Based on the Queue ADT specification, an application programmer has two ways to check for an empty queue. Describe them and discus when one approach might be preferable to the other approach.


4. Discuss the relative efficiency of the enqueue and dequeue operations for fixed-front and floating-front approaches to an array-based implementation of a queue.


5. This discussion is based on The Card Game of War application case study in Chapter 5. Implement the program and answer the following:

a. Can a game of War end in a tie? If not, why  not? If so, explain how, and describe what our War program would do in that case.

b. When you play cards, you normally shuffle the deck several times before playing. Yet the shuffling algorithm used in our program walks through the array of cards only once. Explain the difference between these two situations.

c. Suppose only four cards are dealt in a game of War, two to each player. Describe a deck of four cards, such that when dealt, will result in a game of War that continues forever.

d. In the play method of the WarGame class, what is the effect of removing the shuffle method invocation?

Solution Preview :

Prepared by a verified Expert
JAVA Programming: 1 create a recursive factorial program that
Reference No:- TGS0471076

Now Priced at $100 (50% Discount)

Recommended (94%)

Rated (4.6/5)