Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Based Implementations 11. Discuss the relati efficiency of the enqueue and queue

ID: 3861718 • Letter: B

Question

Based Implementations 11. Discuss the relati efficiency of the enqueue and queue for fixed front and approaches to an array-based implementation of queue. 12 Draw the "internal" view of memory for each step the following code sequence: Bnd Queue String> q new Array BndQueue String (5) Array q enqueue ("X") ("M") de queue enqueue ("T") 13 Describe the effects each of the following changes would have on the Array Bnd Queue class: a. Remove the final attribute from the DEFCAP instance variable. Change the value assigned to DEFCAP to 10. Change the value assigned to DEFCAP to -10. d. In the first constructor, change the first statement to queue (T new object [100] e. In the first constructor, change the last statement to rear capacity In the first constructor, change the last statement to the order of the last two statements in the else clause of the enqueue rea r 1: 9. Reverse clause of the method. statements in the else de verse the order of the first two string method and return a In is would create object alrea Empty, change queue that enqueued from the onsider a for a each invoke

Explanation / Answer

As per chegg policy I am answering only 1st question:

1)

#include<iostream>
#include<conio.h>
#include<stdlib.h>
using namespace std;

class ATDQueue
{
int atdq[5];
int rear,front;
public:
queue()
{
rear=-1;
front=-1;
}
void rearprint()
{
   if(front==rear)
{
cout <<"queue under flow";
return;
}
cout <<atdq[rear]<<" ";
               }
               void lengthq()
{
   if(front==rear)
{
cout <<"queue under flow";
return;
}
cout <<rear<<" ";
               }
void enqueueN(int x)
{
if(rear > 4)
{
cout <<"queue over flow";
front=rear=-1;
return;
}
atdq[++rear]=x;
cout <<"inserted" <<x;
}
void dequeueN()
{
if(front==rear)
{
cout <<"queue under flow";
return;
}
cout <<"deleted" <<atdq[++front];
}
void displayq()
{
if(rear==front)
{
cout <<" queue empty";
return;
}
for(int i=front;i<=rear;i++)
cout <<atdq[i]<<" ";
}
};

int main()
{
int choice;
ATDQueue q;
while(1)
{
cout <<" 1.enqueueN 2.dequeueN 3.rear 4.length 5.display 6.exit Enter ur choice";
cin >> choice;
switch(choice)
{
case 1: cout <<"enter the element";
    cin >> choice;
q.enqueueN(choice);
break;
case 2: q.dequeueN(); break;
case 3: q.rearprint();break;
case 4: q.lengthq();break;
case 5: q.displayq();break;
case 6: exit(0);
}
}
return 0;
}

Fixed-front

After four calls to enqueue with arguments ‘A’, ‘B’, ‘C’, and ‘D’:

Dequeue the front element:

Move every element in the queue up one slot

The dequeue operation is inefficient, so we do not use this approach

Floating-front

By using array as a circular structure we can wrap the queue around to the beginnening of the array.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote