The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 4 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Java---
All methods work correctly
Must have a driver class with tests (more than what is listed)
all necessary attributes included with a private access modifier
header comments nad Javadoc included
Implement a queue using an array in class. Make your queue size 5.
An array will need to handle wrap around.
Think about removing from the front of a full queue.
The queue will not be empty, but the items will be in indices 1, 2, 3 and 4 and index 0 will be free and the queue is not longer full.
It would be inefficient to move all elements up in the array. However, the head is now at 1 and the tail is at 4, so you would add the 5th item in index 0.
Queue() creates an empty queue, queue is new and empty.
enqueue(item) adds a new item to the queue, queue is modified.
dequeue() removes and returns an item, queue is modified.
isEmpty() returns a boolean and tests for an empty queue, queue is not modified.
size() returns the int size of the queue, queue is not modified
print() prints the queue from front to rear, queue is not modified.
peek() prints the front element, queue is not modified.
Driver should print the results of the following
enqueue("dog")
enqueue("cat")
enqueue("mouse")
enqueue("pig")
enqueue("bird")
size()
enqueue("puppy")
size()
dequeue()
dequeue()
size()
dequeue()
peek()
dequeue()
dequeue()
Size()
isEmpty()
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly