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
Could Anyone Please Explain To Me What Is Supervised Learning In Machine Learning? I encourage that you explain it in simple wor
nadya68 [22]

Answer:

Kindly check Explanation.

Explanation:

Machine Learning refers to a concept of teaching or empowering systems with the ability to learn without explicit programming.

Supervised machine learning refers to a Machine learning concept whereby the system is provided with both features and label or target data to learn from. The target or label refers to the actual prediction which is provided alongside the learning features. This means that the output, target or label of the features used in training is provided to the system. this is where the word supervised comes in, the target or label provided during training or teaching the system ensures that the system can evaluate the correctness of what is she's being taught. The actual prediction provided ensures that the predictions made by the system can be monitored and accuracy evaluated.

Hence the main difference between supervised and unsupervised machine learning is the fact that one is provided with label or target data( supervised learning) and unsupervised learning isn't provided with target data, hence, it finds pattern in the data on it's own.

A to B mapping or input to output refers to the feature to target mapping.

Where A or input represents the feature parameters and B or output means the target or label parameter.

4 0
3 years ago
Which command is used to format a partition on a hard disk drive with the ext4 filesystem?
FinnZ [79.3K]
Mkfs -t ext4 /dev/file
5 0
3 years ago
How do i write this in c++ = scnr.nextInt();<br> please help
LenaWriter [7]
Int whatever = scnr.nextInt();



Although usually when a class has a next* member function, it usually needs to check that there IS a next, that you haven't reached the end. Without knowing the class that scnr was instantiated from, I can't guess.
7 0
3 years ago
What is a blog that is set up for advertising purposes and used to send website links and other spam? A. splog B. adlog C. qlog
Alex_Xolod [135]

A. Splog. also known as "spam blog"

3 0
2 years ago
Read 2 more answers
Have you seen this ProFlipperz Review? It is a course on how to flip every day household items for a profit.
Nadusha1986 [10]

Well if you have one I know it's cool but don't flip it all the time

Explanation:

6 0
2 years ago
Other questions:
  • Wendy Patel is entering college and plans to take the necessary classes to obtain a degree in architecture. Research the program
    12·1 answer
  • Suppose you have an int variable called number. What Java expression produces the second-to-last digit of the number (the 10s pl
    15·1 answer
  • Students who respond promptly to e-mails are following which netiquette rule?
    13·2 answers
  • Accepting criticism is a trait of what people?
    5·1 answer
  • What are minimum computer requirements for a software program?
    5·1 answer
  • You are implementing a new application control solution. Prior to enforcing your application whitelist, you want to monitor user
    5·1 answer
  • Give four advantages for ssd compared to hdd
    15·2 answers
  • Complete the sentence.
    5·1 answer
  • Red + blue =<br>Red + green =<br>Magenta - blue =<br>Yellow - green =<br>Cyan - blue =​
    9·1 answer
  • How does social network use message to entertain?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!