![]() But I don't know how should I check this code. I tried to write this code and here's what I wrote. STEP 4 If the dequeue stack is empty, we pop everything from the enqueue stack and push it onto the dequeue stack. STEP 3 We dequeue by popping from the dequeue stack. STEP 2 We enqueue by pushing onto the enqueue stack. It should support generic type parameter and array resizing (both growing and shrinking), but it doesn't have to support iterators.Hints:Queue is a FIFO data structure the API for a queue contains enqueue, dequeue,size and isEmpty methods in addition to the constructor you don't have to implement toString. STEP 1 We have two stacks, one for enqueueing and one for dequeueing. ![]() Write a generic Queue class which uses an array(not a link list) as a memory storage. Suppose the front is at the beginning of the array (starting at position 0). ![]() But once if queue becomes full and later if elements are dequeued, we have to. In our midterm exam teacher asked us to do this question below: One way to implement the queue is to use an array. In a normal Queue Data Structure, we can insert elements until queue becomes full. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |