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
AVprozaik [17]
3 years ago
8

Say you have a random, unordered list containing 4096 four-digit numbers. Describe the most efficient way to: sort the list and

then search for 100 elements within the list, and analyze the expected run time for this specific list's sorting and searching.
Engineering
1 answer:
Debora [2.8K]3 years ago
6 0

Answer:

Answer explained below

Explanation:

It is given that numbers are four-digit so maximum value of a number in this list could be 9999.

So we need to sort a list of integers, where each integer lies between [0,9999].

For these given constraints we can use counting sort which will run in linear time i.e. O(n).

--------------------------------------------------------------------------------

Psuedo Code:

countSort(int numList[]) {

int count[10000];

count[i] = 0; for all i;

for(int num in numList){

count[num]+= 1;

}

return count;

}

--------------------------------------------------------------------------------

Searching in this count array will be just O(1).

E.g. Lets say we want to search if 3 was present in the original list.

Case 1: it was present in the original list:

Then the count[3] would have been incremented by our sorting algorithm. so in case element exists then count value of that element will be greater than 0.

Case 2: it was not present:

In this case count[3] will remain at 0. so in case element does not exist then count of that element will be 0.

So to search for an element, say x, we just need to check if count[x]>0.

So search is O(1).

Run times:

Sorting: O(n)

Search: O(1)

You might be interested in
Which of the following is not used for setting out right angles
aliina [53]
Optical squares are simple sighting instruments used to set out right angles. They can be provided either with mirrors or with one or two prisms. Because of practical difficulties in using squares with mirrors, they have been replaced by squares with prisms: "prismatic squares".
4 0
3 years ago
Your new mobile phone business is now approaching its first anniversary and you are able to step back and finally take a deep br
Leya [2.2K]

Answer

The answer and procedures of the exercise are attached in the following archives.

Step-by-step explanation:

You will find the procedures, formulas or necessary explanations in the archive attached below. If you have any question ask and I will aclare your doubts kindly.  

7 0
3 years ago
Carbon dioxide (CO2) is compressed in a piston-cylinder assembly from p1 = 0.7 bar, T1 = 320 K to p2 = 11 bar. The initial volum
tekilochka [14]

Answer:

W_{12}=-53.9056KJ

Part A:

Q=-7.03734 KJ/Kg (-ve sign shows heat is getting out)

Part B:

Q=1.5265KJ/Kg (Heat getting in)

The value of Q at constant specific heat is approximately 361% in difference with variable specific heat and at constant specific heat Q has opposite direction (going in) than Q which is calculated in Part B from table A-23. So taking constant specific heat is not a good idea and is questionable.

Explanation:

Assumptions:

  1. Gas is ideal
  2. System is closed system.
  3. K.E and P.E is neglected
  4. Process is polytropic

Since Process is polytropic so  W_{12} =\frac{P_{2}V_{2}-P_{1}V_{1}}{1-n}

Where n=1.25

Since Process is polytropic :

\frac{V_{2}}{V_{1}}=(\frac{P_{1}}{P_{2}})^{\frac{1}{1.25}} \\V_{2}= (\frac{P_{1}}{P_{2}})^{\frac{1}{1.25}} *V_{1}

V_{2}= (\frac{0.7}{11})^{\frac{1}{1.25}} *0.262\\V_{2}=0.028924 m^3

Now,W_{12} =\frac{P_{2}V_{2}-P_{1}V_{1}}{1-n}

W_{12} =\frac{11*0.028924-0.7*0.262}{1-1.25}(\frac{10^{5}N/m^2}{1 bar})(\frac{1  KJ}{10^{3}Nm})

W_{12}=-53.9056KJ

We will now calculate mass (m) and Temperature T_2.

m=\frac{P_{1}V_{1}}{RT_{1}}\\ m=\frac{0.7*0.262}{\frac{8.314KJ}{44.01Kg.K}*320}(\frac{10^{5}N/m^2}{1 bar})(\frac{1  KJ}{10^{3}Nm})\\m=0.30338Kg

T_{2} =\frac{P_{2}V_{2}}{Rm}\\ m=\frac{11*0.028924}{\frac{8.314KJ}{44.01Kg.K}*0.30338}(\frac{10^{5}N/m^2}{1 bar})(\frac{1  KJ}{10^{3}Nm})\\T_{2} =555.14K

Part A:

According to energy balance::

Q=mc_{v}(T_{2}-T_{1})+W_{12}

From A-20, C_v for Carbon dioxide at 300 K is 0.657 KJ/Kg.k

Q=0.30338*0.657(555.14-320)+(-53.9056)

Q=-7.03734 KJ/Kg (-ve sign shows heat is getting out)

Part B:

From Table A-23:

u_{1} at 320K = 7526 KJ/Kg

u_{2} at 555.14K = 15567.292 (By interpolation)

Q=m(\frac{u(T_{2})-u(T_{1})}{M} )+W_{12}

Q=0.30338(\frac{15567.292-7526}{44.01} )+(-53.9056)

Q=1.5265KJ/Kg (Heat getting in)

The value of Q at constant specific heat is approximately 361% in difference with variable specific heat and at constant specific heat Q has opposite direction (going in) than Q which is calculated in Part B from table A-23. So taking constant specific heat is not a good idea and is questionable.

7 0
4 years ago
The artifacts that expand what humans are able to do are called:.?
omeli [17]
Where you from?England has so many school subjects,but my country hasn’t got it.Do you like it
5 0
3 years ago
If a machine guard is missing or needs repair, you should ______________.
Gelneren [198K]
B)
Step by step explanation
7 0
3 years ago
Read 2 more answers
Other questions:
  • What does the plasma membrane do
    9·1 answer
  • The ________ is the part of the drill press that holds and rotates the cutting tool.
    7·2 answers
  • A vertical plate has a sharp-edged orifice at its center. A water jet of speed V strikes the plate concentrically. Obtain an exp
    6·1 answer
  • Which of the following wouldn't be pictured on a fan motor's ladder logic diagram? A. Auxiliary contacts B. two Push-button cont
    9·1 answer
  • The annual average of solar photovoltaic energy in Phoenix is 6,720
    8·1 answer
  • Which step in the engineering design process most likely broke down in the following scenario?
    11·1 answer
  • How does distribution add value to goods and services being sold,
    8·2 answers
  • A gas turbine power plant is being designed using an air-standard Brayton cycle. Air enters the compressor with a volumetric flo
    11·1 answer
  • Technician A says that the connecting rod and main bearing caps should be marked before removing to ensure that they can be inst
    5·1 answer
  • Phosphorus and nitrogen are included in which category of water pollutants?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!