Implement queue using dynamic memory allocation, such that the implementation should follow the following constraints. a. The
Question:
Implement queue using dynamic memory allocation, such that the implementation should follow the following constraints.
a. The user should use memory allocation from the heap using new operator. In this, you need to take care of the max value in the queue.
b. Once you are done with the above exercise and you are able to test your queue. Then you can add some more complexity to your code. In add() function when the queue is full, in place of printing, “Queue is full” you should allocate more space using new operator.
c. Once you are done with the above exercise. Now in remove function once you are below half of the capacity of the queue, you need to decrease the size of the queue by half. You should add one more variable "min" to queue so that you can track what is the original value capacity passed at initialization()
function. Moreover, the capacity of the queue will not go below the value passed in the initialization.
(If you are not able to solve the above exercise, and then have a look into stack chapter, where we have done similar problems for stack)
Step by Step Answer:
Problems Solving In Data Structures And Algorithms Using C++
ISBN: 9789356273177
2nd Edition
Authors: Hemant Jain