1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
skad [1K]
2 years ago
14

Examine the following declarations and definitions for the array-based implementations for the Stack and Queue ADTs. Assume that

exception class PushOnFullStack and class PopOnEmptyStack have been defined and are available. Read the following code segment and fill in blank #6.
class StackType
{

public:

StackType();

void Push(StackItemType item);

void Pop();

private:

int top;

ItemType items[MAX_STACK];

};

void StackType::StackType()

{

top = -1;

}

void StackType::Push(ItemType item)

{

__________________ // 1

___________________; // 2

__________________; // 3

___________________; // 4

}

class QueType

{

public:

// prototypes of QueType operations

// go here

private:

int front;

int rear;

ItemType items[MAX_QUEUE];

}

void QueType::QueType()

{

front = MAX_QUEUE - 1;

rear = MAX_QUEUE - 1;

}

Boolean QueType::IsEmpty()

{

return (rear == front);

}

void QueType::Enqueue(ItemType item)

{

____________________; // 5

____________________; // 6

}

[1] rear = (rear +1) % MAX_QUEUE
[2] items[rear] = item
[3] rear = (rear % MAX_QUEUE) + 1
[4] items[front] = item
Computers and Technology
1 answer:
otez555 [7]2 years ago
8 0

Answer:

The codes for the respective blanks are given below with appropriate comments for better understanding

Explanation:

<u>FOR 1 TO 4</u>

Void StackType::Push(ItemType item)

{

if(top == MAX_STACK - 1) // means stack is full so we need to throw the PushOnFullStack exception

throw PushOnFullStack ; // You can use this class and appropriate method to deal with exception like printing that stack is full so can not push the current item

top ++ ;// increment the top to accumulate the next item

items[top] = item; // put the item into the place identified

}

<u>FOR 5 AND 6</u>

Void Quetype::enqueue(itemType item)

{

if (rear==MAX_QUEUE && front==0) // queue is full so can not enqueue

//Handle the queue full exception here, may be print this

}else

{

items[rear] = item;

rear ++;

}

You might be interested in
Which of the following programs can open a bitmap file?
choli [55]
Windows paint can be used to open a bitmap file. Usually, when you have a picture, you can use that to edit it.
Also, on a side note, notepad is specifically used for html codes. 

Answer: Windows Paint
4 0
3 years ago
Read 2 more answers
National ISPs usually offer fewer services and have a smaller technical support staff than regional ISPs.
choli [55]

Answer:

um not sure

Explanation:

5 0
2 years ago
Which should be addressed by stakeholders when reviewing the problem statement? Select all that apply. All possible outcomes hav
kumpel [21]

Answer:

  • The problem as they see it has been addressed
  • The solution proposed will meet their needs
  • The needs of their colleagues are being met
  • All issues and constraints have been identified

Explanation:

The stakeholders in a project or business involves every human resource of the business/project that is essential to the successful completion of the business/project at hand.

The factors to be addressed by stakeholders when reviewing a problem statement is very important for the success of the project hence : the problem as seen in the problem statement has to be addressed, the solution been proposed to solve every problem identified should meet the needs of every stakeholder, also every stakeholder in a project has to be carried along hence the need of every stakeholder has to be considered as well.

7 0
3 years ago
You are training to complete in a local 5K run. You record your time scores in minutes after completing seven practice runs. Wri
trapecia [35]

Answer:

Following are the program to this question:

#include <iostream>//defining header file

using namespace std;

float Avg(float sum, int n)//defining method Avg that accepts float parameter

{

float average=sum/n;//defining float variable average that holds average value  

return average;//return average

}

int main()//defining main method

{

float ar[ ] = {24.1,24.5,24.4,23.8,28.2,29.1,27.4};//defining float array

float sum;//defining float variable sum

int n=7,i;//defining integer variable  

for (i = 0; i <n; i++)//defining loop to count total of array

{

sum=sum+ar[i];//add value in sum variable

}

cout<<"The average is: "<<Avg(sum,n);//use print method to call and print method return value

return 0;

}

Output:

The average is: 25.9286

Explanation:

In the above code, the float method "Avg" is declared, that accepts two parameters, that is "sum and n", inside the method, a float variable average is declared that divides and returns its values.

In the main method a float array "ar" is declared that holds values, in the next line, float variable "sum" and integer variable "n, j" is used.

In for loop, the "i" variable is used to add array values in the sum variable and pass into cout to call the "Avg" method and print its return value.

3 0
2 years ago
You can use pen and highlighter tools to emphasize information on a slide during a PowerPoint presentation. These tools are avai
Savatey [412]
ANSWER:
C. Slide Show toolbar
5 0
3 years ago
Other questions:
  • Many malware attacks are ____ attacks, which involve more than one type of malware and/or more than one type of transmission met
    6·1 answer
  • Which of the following Internet protocols is MOST important in reassembling packets and requesting missing packets to form compl
    11·1 answer
  • Which term is defined as an exploit that takes place before the security community or software developer knows about the vulnera
    12·1 answer
  • When looking at a relationship between two tables on an ERD, the _____ table can be identified by the presence of a foreign key
    8·1 answer
  • Suppose the fixed width of an aside element in a fixed layout is 300 pixels, and the fixed width of its parent element (body) is
    15·1 answer
  • The template code provided is intended to check whether an integer entered by the user is outside of the range 20-29 (inclusive)
    9·1 answer
  • Who is the best Attack on Titan Character?
    12·2 answers
  • The most important part of a computer​
    14·2 answers
  • How does the issue of cybersecurity relate to the internet of things?.
    5·1 answer
  • Which statement correctly describes the difference between an IP address and a MAC address for a
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!