subject
Business, 14.02.2020 22:25 nsaduadhq69831

In this assignment, you will be implementing your own Array-Based Stack (ABS) and Array-Based Queue. A stack is a linear data structure which follows the last in, first out (LIFO) property. LIFO means that the data most recently added is the first data to be removed. (Imagine a stack of books, or a stack of papers on a desk—the first one to be removed is the last one placed on top.) A queue is another linear data structure that follows the first in, first out (FIFO) property. FIFO means that the data added first is the first to be removed (like a line in a grocery store-- the first person in line is the first to checkout).

Stack Behavior

Push – Add something to the top of the stack.

Pop – Remove something from the top of the stack and return it,

Example of LIFO operations-the data most recently added is the first to be removed

Queue Behavior

Enqueue – Add something to end of the queue.

Dequeue – Remove something from the front of the queue.

Example of FIFO operations-the newest data is last to be removed

Description

Your ABS and ABQ will be template classes, and thus will be able to hold any data type. (Many data structures follow this convention—reuse code whenever you can!) As with previous classes that use dynamic memory, you must be sure to define The Big Three: The Copy Constructor, the Assignment Operator, and the Destructor.

Data will be stored using a dynamically allocated array (hence the array-based stack and queue). You may use any other variables/function in your class to make implementation easier.

By default, your ABS and ABQ will have a scale factor 2.0f.

Attempting to push() or enqueue() an item onto an ABS/ABQ that is full will resize the current capacity to current_capacity*scale_factor.
When calling pop() or dequeue(), if the "percent full" (e. g. current size / max capacity) becomes strictly less than 1/scale_factor, resized the storage array to current_capacity/scale_factor.
Why increase (or decrease) the size by any amount other than one?

Short performance!

If you are increasing or decreasing the size of a container, it’s reasonable to assume that you will want to increase or decrease the size again at some point, requiring another round of allocate, copy, delete, etc.

Increasing the capacity by more than you might need (right now) or waiting to reduce the total capacity allows you to avoid costly dynamic allocations, which can improve performance—especially in situations in which this resizing happens frequently. This tradeoff to this approach is that it will use more memory, but this speed-versus-memory conflict is something that programmers have been dealing with for a long time.

An example of the resizing scheme to be implement on a stack.

ansver
Answers: 2

Another question on Business

question
Business, 22.06.2019 08:40
Mcdonald's fast-food restaurants have a well-designed training program for all new employees. each new employee is supposed to learn how to perform standardized tasks required to maintain mcdonald's service quality. due to labor shortages in some areas, new employees begin work as soon as they are hired and do not receive any off-the-job training. this nonconformity to standards creates
Answers: 2
question
Business, 22.06.2019 20:10
Mikkelson corporation's stock had a required return of 12.50% last year, when the risk-free rate was 3% and the market risk premium was 4.75%. then an increase in investor risk aversion caused the market risk premium to rise by 2%. the risk-free rate and the firm's beta remain unchanged. what is the company's new required rate of return? (hint: first calculate the beta, then find the required return.) do not round your intermediate calculations.
Answers: 2
question
Business, 22.06.2019 21:00
Reagan corporation is a wholesale distributor of truck replacement parts. initial amounts taken from reagan's records are as follows:
Answers: 1
question
Business, 22.06.2019 22:50
Suppose that the u.s. dollars-mexican pesos exchange rate is fixed by the u.s. and mexican governments. assume also that labor is mobile between the united states and mexico due to low transportation costs.which of the following situations is likely to happen as a result of a simultaneous increase in the demand for u.s. goods and decrease in the demand for mexican goods? (pick mexican unemployment rate increases, and the country undergoes bad economic times for a sustained u.s. unemployment rate increases, and the country undergoes bad economic times for a sustained mexican unemployment rate rises at first, but it soon drops as unemployed mexicans move to the united states for mexican unemployment rate rises at first, but then it drops as mexican pesos depreciate against u.s. dollars.
Answers: 1
You know the right answer?
In this assignment, you will be implementing your own Array-Based Stack (ABS) and Array-Based Queue....
Questions
question
Mathematics, 19.12.2021 06:20
question
English, 19.12.2021 06:20
question
Computers and Technology, 19.12.2021 06:30
question
Mathematics, 19.12.2021 06:30
Questions on the website: 13722363