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 00:00
Which statement about the cost of the options is true? she would save $1,000 by choosing option b. she would save $5,650 by choosing option a. she would save $11,200 by choosing option b. she would save $11,300 by choosing option a.
Answers: 2
question
Business, 22.06.2019 10:30
Zapper has beginning equity of $257,000, net income of $51,000, dividends of $40,000 and investments by stockholders of $6,000. its ending equity is
Answers: 2
question
Business, 22.06.2019 20:20
As you have noticed, the demand for flip phones has drastically reduced, and there are only a few consumer electronics companies selling them at extremely low prices. also, the current buyers of flip phones are mainly categorized under laggards. which of the following stages of the industry life cycle is the flip phone industry in currently? a. growth stage b. maturity stage c. decline stage d. commercialization stage
Answers: 2
question
Business, 22.06.2019 22:00
In 2018, laureen is currently single. she paid $2,800 of qualified tuition and related expenses for each of her twin daughters sheri and meri to attend state university as freshmen ($2,800 each for a total of $5,600). sheri and meri qualify as laureen’s dependents. laureen also paid $1,900 for her son ryan’s (also laureen’s dependent) tuition and related expenses to attend his junior year at state university. finally, laureen paid $1,200 for herself to attend seminars at a community college to her improve her job skills.what is the maximum amount of education credits laureen can claim for these expenditures in each of the following alternative scenarios? a. laureen's agi is $45,000.b. laureen’s agi is $95,000.c. laureen’s agi is $45,000 and laureen paid $12,000 (not $1,900) for ryan to attend graduate school (i.e, his fifth year, not his junior year).
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, 05.01.2021 19:30
question
Mathematics, 05.01.2021 19:30
question
Computers and Technology, 05.01.2021 19:30
question
Mathematics, 05.01.2021 19:30
question
History, 05.01.2021 19:30
question
Health, 05.01.2021 19:30
question
Mathematics, 05.01.2021 19:30
question
Mathematics, 05.01.2021 19:30