Question: Q4 [20M). Consider a deque abstract data type (ADT) which allows insertions and deletions from either end of the queue. Consider a variant of deque,
Q4 [20M). Consider a deque abstract data type (ADT) which allows insertions and deletions from either end of the queue. Consider a variant of deque, that is, dequeRear, which allows insertions at either end of the queue but deletions only from the rear. You have to implement dequeRear using two stacks. Write algorithms for the following operations of dequeRear ADT using two stacks: enqueue AtRear (): It inserts the element at rear end. enqueue AtFront (): It inserts the element at front end. dequeue FromRear (): deletes the element from rear end. front (); returns the element at front. rear(); returns the element at rear. Also, a tabular form, write the time and space complexity of the above operations. Marks would be given for efficient and neatly written algorithms
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
