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
Question 1
Ivanshal [37]

Answer:

Q1. B

Q2. D

Explanation:

3 0
2 years ago
Read 2 more answers
Generally considered to be the most important information security policies, what item below defines the actions a user may perf
tamaranim1 [39]

Answer:

A. Acceptable use policies

Explanation:

These specific actions that the user may perform are all described in the acceptable use policy. The company usually requires that the user read and sign this policy before being granted a network ID into the system itself. By signing this agreement the individual user agrees to perform ONLY the actions listed in the agreement and nothing else and are restricted from unauthorized areas.

3 0
3 years ago
what's that one game where you have powers like telekenesis, it's also an open world GTA type of game
torisob [31]
Is it infamous for the playstation 3?
4 0
3 years ago
Read 2 more answers
Identify the 1950s programming languages. Choose all that apply.
erastova [34]

Answer:????????????????

Explanation: So sorry

6 0
3 years ago
I need help with coding, why isn't this command working pls help
astraxan [27]

Answer:

You type error word

8 0
3 years ago
Read 2 more answers
Other questions:
  • Design a generic post-implementation evaluation form. The form should consist of questions that you could use to evaluate any in
    13·1 answer
  • Are engineers who help to develop products and projects by creating technical drawings
    15·1 answer
  • Select the correct answer.
    14·2 answers
  • What type of maintenance is required of a computer’s power supply to ensure that it remains in working order?
    15·2 answers
  • What is a Slide Master? A. the placeholder used to insert objects B. the sequence of slides in a presentation C. the default des
    14·1 answer
  • Which of these best represents a call to action?
    7·2 answers
  • In relation to data science,advances in technology has made it more feasible to do what
    5·1 answer
  • The next few questions will be based on interpretations of a topographic map from East Brownsville, TX. To answer these question
    15·1 answer
  • An application's certificate indicates the application -
    5·1 answer
  • How is the architecture converted into software code? Elaborate the steps its passes through with help of examples / Diagram.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!