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
What type of intersection is this?
mote1985 [20]
Diverging Diamond Interchange
6 0
3 years ago
A ballistic pendulum consists of a 3.60 kg wooden block on the end of a long string. From the pivot point to the center‐of‐mass
Pavel [41]

Answer:

17.799°

Explanation:

When the bullet hits the block at that time the momentum is conserved

So, initial momentum = final momentum

P_i=P_f

So 28\times 10^{-3}\times 210=(3.6+0.028)v_f

v_f=1.6207\ m/sec

Now energy is also conserved

So \frac{1}{2}\times (3.6+0.028)\times 1.6207^2=(3.6+0.028)\times 9.81\times 2.8(1-cos\Theta )

cos\Theta =0.8521So\ \Theta =17.799^{\circ}

3 0
3 years ago
How to code the round maze in CoderZ?
dlinn [17]

Answer:

hola

Explanation:

5 0
3 years ago
A steel bolt has a modulus of 207 GPa. It holds two rigid plates together at a high temperature under conditions where the creep
VikaD [51]

Answer:

14.36((14MPa) approximately

Explanation:

In this question, we are asked to calculate the stress tightened in a bolt to a stress of 69MPa.

Please check attachment for complete solution and step by step explanation

7 0
3 years ago
A general contractor has received plans for a new high-rise hotel in an urban area. The hotel will be 12 stories tall and will h
liberstina [14]

Answer:

Ano klassing tanong yn?

Explanation:

Ang taas namn yn? Paki linaw po para matulungan po kita.!!

8 0
3 years ago
Other questions:
  • Calculate the maximum internal crack length allowable for a 7075-T651 aluminum alloy component that is loaded to a stress one-ha
    15·1 answer
  • A hanging wire made of an alloy of nickel with diameter 0.19 cm is initially 2.8 m long. When a 59 kg mass is hung from it, the
    15·1 answer
  • Nitrogen can be liquefied using a Joule-Thomson expansioni process. This is done by rapidlyl and adiabatically expandign cold ni
    15·1 answer
  • Two gases—neon and air—are expanded from P1 to P2 in a closed-system polytropic process with n = 1.2. _____ produces more work w
    7·1 answer
  • Shear strain can be expressed in units of either degrees or radians. a)True b)- False
    10·1 answer
  • Which type of load generates a magnetic field?
    12·1 answer
  • Tech A says that proper footwear may include both leather and steel-toed shoes. Tech B says that when working in the shop, you o
    15·1 answer
  • A Styrofoam cup (k = 0.010 W/(m∙ o C)) has cross-sectional area (A) of 3.0 x 10 −2m 2 . The cup is 0.589 cm thick (L). The tempe
    12·1 answer
  • For a nozzle-duct system shown in Fig Q3, the nozzle is designed to produce a Mach number of 2.8 with y = 1.4, The inlet conditi
    14·1 answer
  • Which of the given strategies is specifically a competitive advantage sustainment strategy?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!