Question: Given a typical Queue q with elements [E,D,C,B,A] (where Front/left of at E and Rear/right of Queue at A), determine and list elements of the

Given a typical Queue q with elements [E,D,C,B,A] (where Front/left of at E and Rear/right of Queue at A), determine and list elements of the updated Queue in the similar form (Front/left and Rear/right), after the following execution: q.enqueue( q.dequeue () ) q.enqueue G ) q.dequeue() [2 marks] 5/6 b) Given a typical Stack s with elements [T,W,X,Y,Z] (where Top/left of Stack at T) and a typical Queue q with elements [E,D,C,B,A) (where Front/left of Queue at E and Rear/right of Queue at A), determine and list elements of the updated Stack and those of the updated Queue in their similar forms after the following execution: q.enqueue( s.pop() ) s.push( R ) q.enqueue( s.peek() ) s.push( q. dequeue() ) q.enqueue( s.pop() ) (4 marks] COPACE c) Given a Python Queue class implemented with the abstract data type (ADT) below, write a new method popqueue(), which will pop\" (remove and return) the last-in element from the rear end of the queue. Operation (Queue) Description sizeQ(): int GIVEN: Get (and return) the size of the queue (total number of elements) enqueue (elt): GIVEN: Insert elt into Queue dequeue():elt GIVEN: Remove and return) element from Queue popqueue():elt Remove and return) the last-in element from rear end of Queue c) Given a Python Queue class implemented with the abstract data type (ADT) below, write a new method popqueue (), which will \"pop\" (remove and return) the last-in element from the rear end of the queue. Operation (Queue) Description sizeQ(): int GIVEN: Get (and return) the size of the queue (total number of elements) enqueue (elt): GIVEN: Insert elt into Queue dequeue():elt GIVEN: Remove and return) element from Queue popqueue():elt Remove (and return) the last-in element from rear end of Queue Finish this new Python popqueue() method, by completing the method body below: def popqueue self ): # remove and return rear elt # body of the method. TO BE COMPLETED by student o No other extra variable could be added including Python's list, except int and range with function range(). No more than 4 lines of typical python code (without semicolon symbol ;) allowed in the method body. * Hint: you may finish this task using its own given methods of the Queue class, and a for loop with function range(). [4 marks) muni Lahe Queen oallom




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