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, 21.06.2019 21:30
What is the eventual effect on real gdp if the government increases its purchases of goods and services by $80,000? assume the marginal propensity to consume (mpc) is 0.75. $ what is the eventual effect on real gdp if the government, instead of changing its spending, increases transfers by $80,000? assume the mpc has not changed. $ an increase in government transfers or taxes, as opposed to an increase in government purchases of goods and services, will result in an identical eventual effect on real gdp. a smaller eventual effect on real gdp. a larger eventual effect on real gdp. no change to real gdp.
Answers: 3
question
Business, 22.06.2019 07:10
In a team environment, a coordinator is? a person with expert knowledge or skills in a particular area the team needs. a good listener who works to resolve social problems among teammates. a leader who team members focus on their tasks. a good networker who likes to explore new ideas and possiblities.
Answers: 2
question
Business, 22.06.2019 12:00
Select the correct answer. martha is a healer, a healthcare provider, and an experienced nurse. she wants to share her daily experiences, as well as her 12 years of work knowledge, with people who may be interested in health and healing. which mode of internet communication can martha use? a. wiki b. email c. message board d. chat e. blog
Answers: 2
question
Business, 22.06.2019 15:50
Evaluate a real situation between two economic actors; it could be any scenario: two competing businesses, two countries in negotiations, two kids trading baseball cards, you and another person involved in an exchange or anything else. use game theory to analyze the situation and the outcome (or potential outcome). be sure to explain the incentives, benefits and risks each face.
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
Biology, 27.06.2020 05:01
Questions on the website: 13722363