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
What type of steel would a motor vehicle body be manufactured from?​
Delvig [45]

Answer:

Stainless steel

Explanation:

Hope I answered your question.

8 0
3 years ago
What is applied technology?
8090 [49]

Answer:

the application of scientific knowledge for practical purposes, especially in industry.

2. machinery and equipment developed from the application of scientific knowledge.

3. the branch of knowledge dealing with engineering or applied sciences.

Explanation:

6 0
3 years ago
Do all websites use the same coding to create?
Sonbull [250]

Answer:

yes.

Explanation:

because all websites use coding

6 0
3 years ago
A student is working with three sealed containers filled with water. The first container is filled with ice. The second is fille
Temka [501]

Explanation:

The three containers each contains water in different states.

Solid state of matter is considered as not compressible because the molecules are already as closely packed as they can be.

The liquid sate of matter has a very minute to no compression ability at all as the molecules are relatively close to each other. Compression is difficult to achieve in the liquid state.

In the gaseous state of matter, the molecules have broken free of one another, and are fairly spaced one from another. This means that gases can be easily compressed.

Pressing down on the plunger, the container containing ice can't be compressed at all so it's volume stays the same.

For the container filled with water, only a minute compression can be achieved with great difficulty hence, the volume reduces by an insignificant amount.

For the container filled with vapour, compression can be easily achieved and the volume reduces significantly.

6 0
3 years ago
What is the pitch circle diameter of a 50-tooth spur gear having a circular pitch of 0.375 inch
Dmitrij [34]

Answer:

Pitch circle diameter = 5,66 inch

Explanation:

<u>According to the pitch circle diameter formula</u>

      <em>Dc= Dp - 2b</em> ; where Dp= primitive diameter, b= dedendum of the tooth and also the dedendum formula is b= 1,25 Pc/π.

     The definition of primitive diameter is equal to (Pc*Z)/π ; Pc= circular pitch and Z= number of teeths.

    <u>Replacing in the formula </u>

        ⇒ Dc= (Pc*Z)/π - 2* 1,25 Pc/π,    Pc= 0,375 ; Z=50

  In conclusion the pitch circle diameter is equal to:

            Dc= 5,66 inch.      

   

         

<h3>           </h3>

 

   

4 0
3 years ago
Other questions:
  • A structure that extends from a bridge to<br>form a firm foundation​
    6·2 answers
  • What are factor of safety for brittle and ductile material
    5·1 answer
  • Find the Hooke's law of orthotropic and transverse isotropic material in matrix form
    15·1 answer
  • A 2-kg mass of helium is maintained at 300 kPa and 278C in a rigid container. How large is the container, in m3?
    7·1 answer
  • What advantage might there be to having the encoder located on the motor side of the gearhead instead of at the output shaft of
    10·1 answer
  • Write a script (Program 2) to perform t he following matrix operations. Use output commands to clearly output each problem with
    15·1 answer
  • List six possible valve defects that should be included in the inspection of a used valve?
    7·1 answer
  • Deviations from the engineering drawing cannot be made without the approval of the
    15·2 answers
  • Join the pad let <br><br> https://pad let.com/56021812/8g75510tedza5v2a
    6·2 answers
  • This graph shows the US unemployment rate from<br> August 2010 to November 2011
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!