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 US electronics company was the pioneer in home video game consoles
drek231 [11]

This is a list of home video game consoles in chronological order, which includes the very first home video game consoles ever created, such as first generation Pong consoles, from the first ever cartridge console Odyssey, ranging from the major video game companies such as Magnavox, Atari, Nintendo, Sega, NEC, 3DO, SNK, Sony, Microsoft to secondary market consoles.


The list is divided into eras which are named based on the dominant console type of the era, though not all consoles of those eras are of the same type. Some eras are referred to based on how many bits a major console could process. The "128-bit era" (sixth generation) was the final era in which this practice was widespread.[citation needed]


This list does not include other types of video game consoles such as handheld game consoles, which are usually of lower computational power than home consoles due to their smaller size, microconsoles, which are usually low-cost Android-based devices that rely on downloading, or dedicated consoles which have games built in and do not use any form of physical media. Consoles have been redesigned from time to time to improve their market appeal. Redesigned models are not listed on their own.

7 0
3 years ago
Notes on secondary memory​
gladu [14]

Answer:

non-volatile and persistent in nature

7 0
3 years ago
What features are offered by most of the email programs with for receiving and sending messages?
Varvara68 [4.7K]

Answer:

The main features of email is, (1) Attachment :Ability to attach the files along the messages is one of most useful features of email. (2)Address book: It is also most important features of email that allows a user to storing the information.

Explanation:

3 0
3 years ago
What are the advantages and disadvantages of the simulated link strategy?
amid [387]

Answer:

The advantage of the simulated link strategy are:

  • It is easily able to provide the practical feedback to the customers and users while designing the whole system. It also determine the efficiency and the correctness of the design in the stimulated link strategy.
  • In the stimulated link strategy, the sharing and delivering of the data and information is done efficiently without any occurrence of error and interrupt. It is also high flexible technique.

The disadvantage of the simulated link strategy are:

  •   The simulated link strategy is flexible but it is not standardization and also it required more good concept.
  •  This technique is expensive and it is not readily available as it always require validation process.

3 0
3 years ago
A customer reports that recently several files cannot be accessed. The service technician decides to check the hard disk status
Lyrx [107]

Answer:

Back up the user data to removable disk

Explanation:

Before you work on a computer, especially anything that has to do with files not accessible, this might need to format the system because it might either be a virus or other forms of malware. Since backup was done to a different logical partition on the disk, the first thing to do before performing any diagnostic procedures on the disk is to back up the user data to a removable disk in order not to lose the information in the system.

8 0
3 years ago
Other questions:
  • Question 4 (2 points)
    6·2 answers
  • If you press the tab key when you're in in the last cell of a table,
    10·1 answer
  • Big Data often involves a form of distributed storage and processing using Hadoop and MapReduce.
    12·1 answer
  • Which of the following correctly orders the investments from LOWER risk to HIGHER risk?
    7·2 answers
  • Write a program that prints the day number of the year, given the date in the form month-day-year. For example, if the input is
    9·1 answer
  • Andre is teaching a class without the software development cycle while teaching the analyst phase which task should Andre mentio
    8·1 answer
  • What are finger nails made of?-
    12·2 answers
  • A large institution, such as a bank, may have thousands of transactions to process in which no user interaction is required; whi
    5·2 answers
  • _____ involves storing data and running applications outside the company’s firewall. answer grid computing parallel computing cl
    11·1 answer
  • __________ are very simple devices that connect network components, sending a packet of data to all other connected devices.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!