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
1. A glass window of width W = 1 m and height H = 2 m is 5 mm thick and has a thermal conductivity of kg = 1.4 W/m*K. If the inn
emmasim [6.3K]

Answer:

1. \dot Q=19600\ W

2. \dot Q=120\ W

Explanation:

1.

Given:

  • height of the window pane, h=2\ m
  • width of the window pane, w=1\ m
  • thickness of the pane, t=5\ mm= 0.005\ m
  • thermal conductivity of the glass pane, k_g=1.4\ W.m^{-1}.K^{-1}
  • temperature of the inner surface, T_i=15^{\circ}C
  • temperature of the outer surface, T_o=-20^{\circ}C

<u>According to the Fourier's law the rate of heat transfer is given as:</u>

\dot Q=k_g.A.\frac{dT}{dx}

here:

A = area through which the heat transfer occurs = 2\times 1=2\ m^2

dT = temperature difference across the thickness of the surface = 35^{\circ}C

dx = t = thickness normal to the surface = 0.005\ m

\dot Q=1.4\times 2\times \frac{35}{0.005}

\dot Q=19600\ W

2.

  • air spacing between two glass panes, dx=0.01\ m
  • area of each glass pane, A=2\times 1=2\ m^2
  • thermal conductivity of air, k_a=0.024\ W.m^{-1}.K^{-1}
  • temperature difference between the surfaces, dT=25^{\circ}C

<u>Assuming layered transfer of heat through the air and the air between the glasses is always still:</u>

\dot Q=k_a.A.\frac{dT}{dx}

\dot Q=0.024\times 2\times \frac{25}{0.01}

\dot Q=120\ W

5 0
3 years ago
Bob and Alice are solving practice problems for CSE 2320. They look at this code: for(i = 1; i &lt;= N; i = (i*2)+17 ) for(k = i
MissTica

Answer:

Alice is correct.

The loop are dependent.

Explanation:

for(i = 1; i <= N; i = (i*2)+17 )

for(k = i+1; k <= i+N; k = k+1) // notice i in i+1 and i+N

printf("B")

This is a nested for-loop.

After the first for-loop opening, there is no block of statement to be executed rather a for-loop is called again. And the second for-loop uses the value of i from the first for-loop. The value of N is both called from outside the loop.

So, the second for-loop depend on the first for loop to get the value of i. For clarity purpose, code indentation or use of curly brace is advised.

8 0
3 years ago
Read 2 more answers
At a certain location, wind is blowing steadily at 5 mph. Suppose that the mass density of air is 0.0796 lbm/ft3 and determine t
nlexa [21]

Answer:

The radius of a wind turbine is 691.1 ft

The power generation potential (PGP) scales with speed at the rate of 7.73 kW.s/m

Explanation:

Given;

power generation potential (PGP) = 1000 kW

Wind speed = 5 mph = 2.2352 m/s

Density of air = 0.0796 lbm/ft³ = 1.275 kg/m³

Radius of the wind turbine r = ?

Wind energy per unit mass of air, e = E/m = 0.5 v² = (0.5)(2.2352)²

Wind energy per unit mass of air = 2.517 J/kg

PGP = mass flow rate * energy per unit mass

PGP = ρ*A*V*e

PGP = \rho *\frac{\pi r^2}{2} *V*e  \\\\r^2 = \frac{2*PGP}{\rho*\pi *V*e} , r=\sqrt{ \frac{2*PGP}{\rho*\pi *V*e}} = \sqrt{ \frac{2*10^6}{1.275*\pi *2.235*2.517}}

r = 210.64 m = 691.1 ft

Thus, the radius of a wind turbine is 691.1 ft

PGP = CVᵃ

For best design of wind turbine Betz limit (c) is taken between (0.35 - 0.45)

Let C = 0.4

PGP = Cvᵃ

take log of both sides

ln(PGP) = a*ln(CV)

a = ln(PGP)/ln(CV)

a = ln(1000)/ln(0.4 *2.2352) = 7.73

The power generation potential (PGP) scales with speed at the rate of 7.73 kW.s/m

5 0
3 years ago
The properties of the air in the inlet section with A1 = 0.25ab m2 in a converging-diverging channel are given as U1 = 25a,b m/s
NeX [460]

Answer:

nice cake

Explanation:

3 0
3 years ago
If the surface energy of a magnesium oxide - nickel oxide (MgO-NiO) solid solution is 1.05 J/m2 and its elastic modulus is 198 G
Nastasia [14]

Answer:

The maximum length is 3.897×10^-5 mm

Explanation:

Extension = surface energy/elastic modulus

surface energy = 1.05 J/m^2

elastic modulus = 198 GPa = 198×10^9 Pa

Extension = 1.05/198×10^9 = 5.3×10^-12 m

Strain = stress/elastic modulus = 27×10^6/198×10^9 = 1.36×10^-4

Length = extension/strain = 5.3×10^-12/1.36×10^-4 = 3.897×10^-8 m = 3.897×10^-8 × 1000 = 3.897×10^-5 mm

7 0
3 years ago
Other questions:
  • What Type of diploma do you need in order To the get into JMU
    12·1 answer
  • To assist in completing this question, you may reference the Animated Technique Video - MALDI-TOF Mass Spectroscopy. Complete th
    9·1 answer
  • 3/194 The assembly of two 5‐kg spheres is rotating freely about the vertical axis at 40 rev/min with θ = 90°. If the force F whi
    9·1 answer
  • A circular ceramic plate that can be modeled as a blackbody is being heated by an electrical heater. The plate is 30 cm in diame
    15·1 answer
  • Steam enters a turbine at 120 bar, 508oC. At the exit, the pressure and quality are 50 kPa and 0.912, respectively. Determine th
    5·1 answer
  • 500 flights land each day at San Jose’s airport. Assume that each flight has a 5% chance of being late, independently of whether
    5·1 answer
  • A crude fermenter is set up in a shed in the backyard of a suburban house. Under anaerobic conditions with ammonia as the nitrog
    9·1 answer
  • A block of mass M rests on a block of mass M1 = 5.00 kg which is on a tabletop. A light string passes over a frictionless peg an
    14·1 answer
  • Define ways in which you would go about networking to explore opportunities in your career field and obtain more information for
    11·1 answer
  • Which of the following identifies the limitations of green engineering?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!