Question: Stack/Queue Lab A non-coding activity: Draw the step-by-step stack contents, making sure you indicate where top is: .push(Sue); .push(Mike); .peek( ); .pop( ); .push(Tom); .pop(

Stack/Queue Lab

A non-coding activity:

Draw the step-by-step stack contents, making sure you indicate where top is:

.push(Sue);

.push(Mike);

.peek( );

.pop( );

.push(Tom);

.pop( );

.push(Bob);

.peek( );

.push(Joe);

.push(Jill);

Draw the step-by-step queue contents, making sure you indicate where front and back are:

.push(Sue);

.push(Mike);

.peek( );

.pop( );

.push(Tom);

.push(Bob);

.peek( );

.push(Joe);

.push(Jill);

.pop( );

A coding activity:

Use the Java API to research/review various members of the class Stack.

Create two empty stacks

Verify that each stack is empty

Add your name to the first stack

Add your age (integer) to the first stack

Add your favorite color to the first stack

Add your ideal hourly wage (double) to the first stack

Verify that the first stack is not empty

Print the top item in the first stack

See if the color magenta is in the first stack

See if YOUR color is in the first stack

Move all the items from stack1 to stack2; print the value of each as you do

Verify that stack2 is not empty

Verify that stack1 is empty

Delete all the items from stack2; print the value of each as you do

Verify that stack2 is empty

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!