Question: Write a class for circular-queue. Length of circular queue will be kept in private section of class. Array for circular-queue, counter for items of queue,
Write a class for circular-queue. Length of circular queue will be kept in private section of class. Array for circular-queue, counter for items of queue, start and end points of queue will be kept in protected section. In public section there will be three functions and a constructor. Constructor will be used to initialize all variables and also it will be possible to determine length of queue just by sending a parameter to constructor. set function will be used to send an item into queue; if all locations are occupied, function will print Queue is Full message on screen. get function will just return current item from queue; if all locations are empty, function will print Queue is Empty message on screen. Finally, showqueue function will just return length of queue. IMPORTANT: Circular queues use FIFO or LILO principle. Stacks use LIFO or FILO principle
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
