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
What type of redundant storage configuration is most common for hosting the operating system and applications on a server
Ne4ueva [31]

Answer:

RAID 1 is the redundant storage configuration

Explanation:

6 0
2 years ago
What do you mean by word-wrap?
olga2289 [7]

Answer:

it is also know as line breaking

Explanation:

is breaking a section of text into lines so that it will fit into the available width of a page, window or other display area

3 0
3 years ago
A(n) _____ allows individuals to create and publish a profile, create a list of other users with whom they share a connection (o
Mice21 [21]

Answer:

Social Networks

Explanation:

Social Network provides a way for users to create a profile, create a list of other users whom they share a connection with. This allows users to connect with other users who share similar interests with them. Businesses can also leverage the power of the social network to boost their sales and gain more reach and visibility.

4 0
3 years ago
To incorporate media such as audio or video into a PowerPoint presentation, a user would first navigate to the _____ tab.
Nadya [2.5K]

The answer is the Insert tab or the recording tab in PowerPoint 2016

You can use the insert tab in most versions of the Microsoft PowerPoint applications to add media files to your presentations. However, we have the recording tab introduced in PowerPoint 2016. This tab can also be used to add a screenshot, a recording, or a video to a slide

3 0
4 years ago
Create a function called howManyUntil(stopNum) where stopNum is an integer from 0 and 99
uysha [10]

Answer:

i dont get it

Explanation:

6 0
3 years ago
Other questions:
  • How do networks help protect data? -by preventing access by more than one person at a time -by restricting access to department
    11·2 answers
  • In order to accomplish the same goal, a person can click and hold down the mouse button and drag to the right, or hold Shift and
    5·2 answers
  • List seven basic internal components found in a computer tower
    13·1 answer
  • Which of the following is not one of the Fatal Four events that cause three out of five construction worker deaths? A. Caught in
    8·2 answers
  • During which part of geologic time were dinosaurs most common?
    11·2 answers
  • ITS MAKING ME TYPE URL CODES NOW!
    6·1 answer
  • &amp;. Give three differences between a<br>web browser<br>and web page​
    11·1 answer
  • What is the binary number for the decimal 1024? ​
    14·2 answers
  • What are three major events in computer science history?
    11·2 answers
  • leon started a project to design and create a new video game for the animation studio where he develops graphics and animations
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!