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]
3 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]3 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 task is not possible with VLOOKUP?
Flauer [41]

Answer:c

Explanation:

4 0
3 years ago
Read 2 more answers
What policy definition can help remind employees in the User Domain about what constitutes suitable use and improper use of corp
Helga [31]

Answer:

so so sorry I don't know

Explanation:

hope fully you'll get the answer

4 0
3 years ago
How can I change my username here at brainly?
velikii [3]

Answer:

Explanation:

LOG OUT AND CHANGE IT

3 0
3 years ago
Read 2 more answers
What is often used to improve the quality of a broadcast?
Karo-lina-s [1.5K]
The answer is relay station.
 Relay station is often used to improve the quality of a broadcast. It is an amplifier for restoring the strength of a transmitted signal. An amplifier is an electronic equipment that increases strength  of signals passing through it. Relay station has been known as America's Friendliest travel center.

8 0
3 years ago
Read 2 more answers
3. Suppose Recruitment and Hiring is one of the Users requirement of HumanResource Management System needs to perform in any org
Mice21 [21]

Answer:

Functional requirements usually define if/then behaviours and include calculations, data input, and business processes. Functional requirements are features that allow the system to function as it was intended. Put another way, if the functional requirements are not met, the system will not work.

Explanation:

7 0
3 years ago
Other questions:
  • To move a file, you use the ____ command along with the source file name and destination name
    5·1 answer
  • What is the best overall approach to education and career development for IT professionals?
    14·1 answer
  • When inside a closed work environment, its okay to openly talk with co-workers about PII
    6·1 answer
  • Enter key is also known as Return key. (True or false)
    13·2 answers
  • #Write a function called hide_and_seek. The function should #have no parameters and return no value; instead, when #called, it s
    7·1 answer
  • All of the following are true of using the database approach to managing data except Group of answer choices Decentralized manag
    6·1 answer
  • 6.8 Code Practice<br> please can have some help please
    8·1 answer
  • What happens to a message when it is deleted?
    5·2 answers
  • What is a key differentiator of Conversational Artificial Intelligence (AI)
    11·1 answer
  • 1.Microsoft Word is a/an ........​
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!