Question: Generate 100 random numbers and add them to a stack and a queue, after print out the content from both stack and queue, sort the

Generate 100 random numbers and add them to a stack and a queue, after print out the content from both stack and queue, sort the data from both in ascending order, then print out again, after being sorted, and go through both the stack a queue and remove an element one at a time till empty then print out a message saying its empty. print out how much time it took to do this process, basically compare the stack and the queue. the stack should use an array with initial size of 50 and increase if need be. the queue should use a linkedlist.

stack should have: push, pop, front, peek, isEmpty

queue: enqueue, dequeue, front, peek, isEmpty

Write this code in Java

Step by Step Solution

3.31 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres a stepbystep breakdown of how to implement the solution in Java including both data structures stack using an array and queue using a linked list Step 1 Define the Stack and Queue Classes 1 Stac... View full answer

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 Programming Questions!