1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
iragen [17]
3 years ago
9

The pointer to the dynamic array is called data, and the size of the dynamic array is stored in a private member variable called

capacity. Write the following new member function: (C++ LANGUAGE)
void bag::triple_capacity( )
// Postcondition: The capacity of the bag's dynamic array has been
// tripled. The bag still contains the same items that it previously
// had.

Do not use the reserve function, do not use realloc, and do not cause a heap leak. Do make sure that both data and capacity have new values that correctly indicate the new larger array.
Computers and Technology
1 answer:
MatroZZZ [7]3 years ago
4 0

Answer:

Following are code to this question:

void bag::triple_capacity()//defining a method bag that uses the scope resolution operator to hold triple_capacity  

{

int* newArray = new int[3*capacity];//defining an array that holds capacity value

for(int x=0;x<capacity;x++)//defining for loop to hold array value

{

newArray[x] = data[x];//holding array value in newArray

}

delete[] data;//using the delete keyword to delete value in array  

data = newArray;//holding array value in data

capacity = capacity*3;//increaing the array size value

}

Explanation:

In this code, a method "bag" is declared that uses the scope resolution operator that holds the triple_capacity method, inside the method an array "newArray" is declared that uses the for loop to hold array value.

In the next step, the delete keyword is declared that delete data value and hold newArray value within it and at the last, it increases the capacity of the array.

You might be interested in
In your own words, describe what Internet Protocols are. Why is it important to have agreed upon protocols?
Anni [7]

Answer:

Internet Protocol refers to a set of rules that govern how data packets are transmitted over a network. Internet protocol describes how data packets move through a network. Its important to have agreed upon protocols because Computers make use of protocols as well, to enable them to communicate. Devices need to communicate. When two devices want to successfully communicate, they must agree to follow some rules about the way they will do it.

8 0
3 years ago
A barcode is a Select one: a. coded instruction needed to control computer hardware. b. confidential computer code required by H
kolezko [41]

A bar code is a  series of bars and spaces representing numbers or letters.

<h3><u>Explanation:</u></h3>

A method that is used for the purpose of representing a data in the form of a picture or image that can be easily understood by the machine. It consists of many lines that has different widths and spaces. They either represent the letter or a number. These are mainly used for the representation of data in the machine understandable format.

For example an UPC-A bar codes has 12 numbers. The numbering system is represented by the first digit. The manufacturer will be represented by the next five digits in it. The product will be represented by the five digits following it. Check digit is represented in the last digit.

5 0
2 years ago
given the numerical value 1010101.11, which of the following number systems is most likely represented.
nasty-shy [4]

Answer:

u have to give me more points

Explanation:

sorry

7 0
3 years ago
Which of the following techniques would a Baroque composer most likely employ to evoke an affect of agitation? Select one:
frez [133]

Answer:

b. Rubato tremolo

Explanation:

Tremolo is a modulation effect that imposes a rhythmic change in volume of sound. Once discovered in electric amplifier circuits, sound engineers and composers like the Baroque now use this low frequency oscillating modulation technique to create emotional piercing effect on their audience to maintain focus.

The low frequency tremolo can be gotten from the vibrating string in guitars, violins etc, and vocal sound, it is also produced from electronic devices created for its purpose. they are called optical tremolo.

5 0
3 years ago
2.Consider the following algorithm and A is a 2-D array of size ???? × ????: int any_equal(int n, int A[][]) { int i, j, k, m; f
Elis [28]

Answer:

(a) What is the best case time complexity of the algorithm (assuming n > 1)?

Answer: O(1)

(b) What is the worst case time complexity of the algorithm?

Answer: O(n^4)

Explanation:

(a) In the best case, the if condition will be true, the program will only run once and return so complexity of the algorithm is O(1) .

(b) In the worst case, the program will run n^4 times so complexity of the algorithm is O(n^4).

5 0
3 years ago
Other questions:
  • For any element in keysList with a value greater than 50, print the corresponding value in itemsList, followed by a space. Ex: I
    8·1 answer
  • Which of the following is important to do when downloading a game to your
    8·1 answer
  • Select the proper ergonomic keyboarding techniques.
    15·2 answers
  • Internally, computers are constructed from circuitry that consists of small on/off switches. What is the most basic circuitry-le
    12·1 answer
  • While in slide show mode, if you are not careful you can close the application by clicking the x on the menu bar. question 38 op
    12·2 answers
  • Which of the operating systems listed below is not proprietary?
    8·1 answer
  • Create a class named Lease with fields that hold an apartment tenant’s name, apartment number, monthly rent amount, and term of
    13·1 answer
  • A10:A20 Refer to values in
    8·1 answer
  • Which of the following sentences use personification 
    9·1 answer
  • A character that <br>is raised and smaller above the baseline is called​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!