subject

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

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:00, hailee232
What is a society that has moved to the internet rather than relying on physical media called
Answers: 2
image
Computers and Technology, 22.06.2019 22:00, robert7248
Competent nonverbal communication involves interacting with others in a manner that is appropriate for which of the following? select all that apply. situation task individuals
Answers: 3
image
Computers and Technology, 23.06.2019 01:20, sosick90501
Write a function balancechemical to balance chemical reactions by solving a linear set of equations. the inputs arguments are: reagents: symbols of reagents in string row array products: symbols of products in string row array elements: elements in the reaction in string row array elcmpreag: elemental composition of reactants in two dimensional numeric array elcmpprdcts: elemental composition of prducts in two dimensional numeric array hint: the first part of the problem is setting up the set of linear equations that should be solve. the second part of the problem is to find the integers from the solution. one way to do this is to mulitiply the rational basis for the nullspace by increasing larger integers until both the left-and right-side integers exist. for example, for the reaction that involves reacting with to produce and : reagents=["ch4", "o2"]; products =["co2", "h2o"]; elements =["c","h", "o"] elcmpreag=[1,4,0;
Answers: 3
image
Computers and Technology, 23.06.2019 01:20, shiann2002
Me with this program in c++ ! computers represent color by combining sub-colors red, green, and blue (rgb). each sub-color's value can range from 0 to 255. thus (255, 0, 0) is bright red. (130, 0, 130) is a medium purple. (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (in other word, equal amounts of red, green, blue yield gray).given values for red, green, and blue, remove the gray part. ex: if the input is 130 50 130, the output is: 80 0 80. thus, find the smallest value, and then subtract it from all three values, thus removing the gray.
Answers: 3
You know the right answer?
Examine the following declarations and definitions for the array-based implementations for the stack...

Questions in other subjects:

Konu
Mathematics, 23.06.2019 04:00