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 10:30
Jack manufacturing company had beginning work in process inventory of $8,000. during the period, jack transferred $34,000 of raw materials to work in process. labor costs amounted to $41,000 and overhead amounted to $36,000. if the ending balance in work in process inventory was $12,000, what was the amount transferred to finished goods inventory?
Answers: 2
question
Business, 22.06.2019 11:40
Vendors provide restaurants with what? o a. cooked items ob. raw materials oc. furniture od. menu recipes
Answers: 1
question
Business, 22.06.2019 16:00
In microeconomics, the point at which supply and demand meet is called the blank price
Answers: 3
question
Business, 22.06.2019 17:00
Zeta corporation is a manufacturer of sports caps, which require soft fabric. the standards for each cap allow 2.00 yards of soft fabric, at a cost of $2.00 per yard. during the month of january, the company purchased 25,000 yards of soft fabric at $2.10 per yard, to produce 12,000 caps. what is zeta corporation's materials price variance for the month of january?
Answers: 2
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, 30.04.2021 14:00
question
Biology, 30.04.2021 14:00
question
English, 30.04.2021 14:00
question
Mathematics, 30.04.2021 14:00
Questions on the website: 13722361