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
Ugo [173]
3 years ago
7

Question 1 (20 points): a. Consider the "circular" array implementation of a queue, similar to ArrayQueue that we studied in cla

ss, where the only difference is that the initial capacity is set to 4 (INITIAL_CAPACITY=4): class ArrayQueue: INITIAL_CAPACITY = 4 def __init__(self): self.data_arr = make_array(ArrayQueue.INITIAL_CAPACITY) self.num_of_elems = 0 self.front_ind = None def __len__(self): … def is_empty(self): … def enqueue(self, elem): … def dequeue(self): … def first(self): … def resize(self, new_cap): … Show the values of the data members: front_ind, num_of_elems, and the contents of each data_arr[i] after each of the following operations. If you need to increase the capacity of data_arr, add extra slots as described in class.

Engineering
1 answer:
MrMuchimi3 years ago
7 0

Answer:

Check the explanation

Explanation:

main. py

class ArrayQueue:

   INITIAL_CAPACITY = 4

   def __init__(self):

       #self. data_arr = make_array(ArrayQueue.INITIAL_CAPACITY)

       self. data_arr = [None] * ArrayQueue.INITIAL_CAPACITY

       self. num_of_elements = 0

       self. front_ind = None

   def __len__(self):

       return self. num_of_elements

   def is_empty(self):

       return self. num_of_elements == 0

   def first(self):

       """ Peak the front of the queue without removing any item. """

       if self. front_ind == None:

           return None

       else:

           return self. data_arr[self.front_ind]

   def enqueue(self, elem):

       """ Add the element to the rear of queue. Extend the queue if necessary. """

       # If queue is empty

       if self. front_ind == None:

           self. front_ind = 0

           self. data_arr[0] = elem

           self. num_of_elements += 1

       else:

           # If the queue is not full

           if self. num_of_elements != len(self. data_arr):

               self. data_arr[(self. front_ind + self. num_of_elements) % len(self. data_arr)] = elem

               self. num_of_elements += 1

           else:

               # Add new cell at the end of data array

               self. data_arr. append(None)

               # Index of new empty cell

               new_cell_index = len(self. data_arr) - 1

               

               # If the last element of queue was the last element of array

               if self. front_ind == 0:

                   self. data_arr[new_cell_index] = elem

             

You might be interested in
A mixture of air and methane is formed in the inlet manifold of a natural gas-fueled internal combustion engine. The mole fracti
german

Answer:

The mass flow rate of the mixture in the manifold is 6.654 kg/min

Explanation;

In this question, we are asked to calculate mass flow rate of the mixture in the manifold

Please check attachment for complete solution and step by step explanation.

4 0
3 years ago
A sand has a natural water content of 5% and bulk unit weight of 18.0 kN/m3. The void ratios corresponding to the densest and lo
Zinaida [17]

Answer:

Relative density = 0.545

Degree of saturation = 24.77%

Explanation:

Data provided in the question:

Water content, w = 5%

Bulk unit weight = 18.0 kN/m³

Void ratio in the densest state, e_{min} = 0.51

Void ratio in the loosest state, e_{max} = 0.87

Now,

Dry density, \gamma_d=\frac{\gamma_t}{1+w}

=\frac{18}{1+0.05}

= 17.14 kN/m³

Also,

\gamma_d=\frac{G\gamma_w}{1+e}

here, G = Specific gravity = 2.7 for sand

17.14=\frac{2.7\times9.81}{1+e}

or

e = 0.545

Relative density = \frac{e_{max}-e}{e_{max}-e_{min}}

= \frac{0.87-0.545}{0.87-0.51}

= 0.902

Also,

Se = wG

here,

S is the degree of saturation

therefore,

S(0.545) = (0.05)()2.7

or

S = 0.2477

or

S = 0.2477 × 100% = 24.77%

7 0
3 years ago
The regulated voltage of an alternator is stated as 13.6 to 14.6 volts at 3000 rpm with the
lions [1.4K]

Answer:

  d)  1 volt​

Explanation:

The allowable range is 1 volt​. The allowed tolerance (deviation from nominal) depends on what the nominal voltage is.

5 0
4 years ago
Please help!!!! WHICH 2 SKILLS N ABILITIES R ESSENTIAL FOR A SHIP CAPTAIN?? A. Good vision B. Public speaking skills C. Leadersh
Brilliant_brown [7]
A and C are the correct answers
6 0
3 years ago
Read 2 more answers
The motor of an electric vehicle runs at an average of 50 hp for one hour and 25 minutes. Determine the total energy. Write the
Sunny_sXe [5.5K]

Answer:

The total energy of the motor of the electric vehicle is 1.902 × 10⁸ joules.

Explanation:

Power is the rate of change of work in time, since given input is average power, the total energy (\Delta E) of the motor of the electric vehicle, measured in joules, is determined by this formula:

\Delta E = \dot W \cdot \Delta t

Where:

\dot W - Average power, measured in watts.

\Delta t - Time, measured in seconds.

Now, let convert average power and time into watts and seconds, respectively:

Average Power

\dot W = (50\,hp)\times \frac{746\,W}{1\,hp}

\dot W = 3.730\times 10^{4}\,W

Time

\Delta t = (1\,h)\times \frac{3600\,s}{1\,h} + (25\,min)\times \frac{60\,s}{1\,min}

\Delta t = 5.100\times 10^{3}\,s

Then, the total energy is:

\Delta E = (3.730\times 10^{4}\,W)\cdot (5.100\times 10^{3}\,s)

\Delta E = 1.902\times 10^{8}\,J

The total energy of the motor of the electric vehicle is 1.902 × 10⁸ joules.

6 0
4 years ago
Other questions:
  • Water at 20oC, with a free-stream velocity of 1.5 m/s, flows over a circular pipe with diameter of 2.0 cm and surface temperatur
    13·1 answer
  • Show from the first principles that, for a perfect gas with constant specific heat capacities
    14·1 answer
  • Ammonia gas is diffusing at a constant rate through a layer of stagnant air 1 mm thick. Conditions are such that the gas contain
    14·1 answer
  • A(n)___ branch circuit supplies two or more receptacles or outlets for lighting and appliances
    10·1 answer
  • 21. How long can food that requires time-temperature control be left in the danger zone?
    7·2 answers
  • Briefly explain how each of the following influences the tensile modulus of a semicrystalline polymer and why:(a) molecular weig
    6·1 answer
  • Two particles have a mass of 7.8 kg and 11.4 kg , respectively. A. If they are 800 mm apart, determine the force of gravity acti
    12·1 answer
  • Question in image. Question from OSHA.
    11·2 answers
  • Why do some ladders have a white tip or reflective tape attached to the tip?
    14·1 answer
  • Which level of acceleration should you use when accelerating on a short highway entry ramp?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!