Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hello can you help solve this problem? Thank you Practise Problem: Given below is the description of class named queueADT implementinga simple queue data structure
Hello can you help solve this problem?
Thank you
Practise Problem: Given below is the description of class named queueADT implementinga simple queue data structure using circular array for storing int type elements. The class components are as follows Data members: maxQueueSize-the variable to store the maximum number of elements permitted in the queueADT queueLen the variable to store the number of elements in the queueADT queueArr the pointer to an int array created dynamically for storing the elements in the queueADT queueHead the variable storing the position of the first queue element in the queueADT (head of the queue) queueTail the variable storing the position of the last queue element in the queueADT (tail of the queue) Member functions A parameterized queueADT constructor with a default int vale equal to 10. The constructor creates a dynamic array with the size given as input parameter, and assigns the address of the array to the queueArr data member. The maxQueueSize value is set as the value passed to constructor. The queuelen value is set to e. The queueHead is initialized with value 0, and queueTail is initialized with the value maxQueuesize 1 initQueue the function initializes the queueADT to an empty state, .e. means queueLen, queueHead are set to 0, and queueTail is set to maxQueueSize 1 visEmpty the function checks if the queueADT is empty or not the queueArr array has empty cells for new elements. The function returns a bool value isFull the function checks if the queueADT is full or not - if the queueArr array has no empty cells, the function returns true, else return false. The function returns a bool value. getFront if the queueADT is not empty, i.e. has at-least one element, the function returns the first element (element at the head of the queue) in the queueADT, else the function prints an error message that "Queue Empty" and returns -999 getEnd if the queueADT is not empty, i.e. has at-least one element, the function returns the last element (element at the tail of the queue) in the queueADT, else the function prints an error message that "Queue Empty" and returns -999 insertQueue the function inserts a new element in the queueADT. The function takes a value of type int as input parameter Precondition the queueADT should not be full Postcondition If the precondition is true, the new value is copied in the next free empty cell at the tail end of the queueArr array. The queueTail marker is updated as (queueTail + 1)%(maxQueueSize). After the copy operation, the number of elements in the queueADT (variable queuelen) s increased by one. If the precondition is not true the function prints "Queue Full" The function does not return anything removeQueue the function removes an element from the queueADT Precondition the queueADT should not be empty Postcondition If the precondition is true, the new value is copied in the next free empty cell in the tail end of the queueArr array. The queueHead marker is updated as (queueHead + 1)%(maxQueueSize). The queueLen counter is decremented by one. If the precondition is not true, the function prints "Queue Empty The function does not return anything 4Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started