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
lions [1.4K]
3 years ago
8

Using a queue.

Engineering
1 answer:
beks73 [17]3 years ago
7 0

Answer:

// Radix Sort

#include<iostream>

using namespace std;

// function to get max value

int getMaximum(int array[], int n)

{

int max = array[0];

for (int i = 1; i < n; i++)

if (array[i] > max)

max = array[i];

return max;

}

// function to get min value

int getMinimum(int array[], int n)

{

int mn = array[0];

for (int i = 1; i < n; i++)

if (array[i] <mn)

mn= array[i];

return mn;

}

//counting sort

void counterSort(int array[], int n, int expo)

{

int out[100]; // out max

int i, count[10] = {0};

// Store count of occurrences in count[]

for (i = 0; i < n; i++)

count[ (array[i]/expo)%10 ]++;

// Change count[i] so that count[i] now contains actual

// position of this digit in out[]

for (i = 1; i < 10; i++)

count[i] += count[i - 1];

// construct the out max

for (i = n - 1; i >= 0; i--)

{

out[count[ (array[i]/expo)%10 ] - 1] = array[i];

count[ (array[i]/expo)%10 ]--;

}

for (i = 0; i < n; i++)

array[i] = out[i];

}

void counterSortDesc(int array[], int n, int expo)

{

int out[100]; // out max

int i, count[10] = {0};

// Store count of occurrences in count[]

for (i = 0; i < n; i++)

count[ (array[i]/expo)%10 ]++;

for (i = 10; i >=1; i--)

count[i] += count[i - 1];

// construct out max

for (i = 0; i >= n-1; i++)

{

out[count[ (array[i]/expo)%10 ] - 1] = array[i];

count[ (array[i]/expo)%10 ]++;

}

// Copy the out max to array[], so that array[] now

// contains sorted numbers according to current digit

for (i = 0; i < n; i++)

array[i] = out[i];

}

// Radix Sort function

void radixsort(int array[], int n)

{

// get maximum number

int m = getMaximum(array, n);

for (int expo = 1; m/expo > 0; expo *= 10)

counterSort(array, n, expo);

}

void radixsortDesc(int array[], int n)

{

// get minimum number

int m = getMinimum(array, n);

for (int expo = 1; m/expo > 0; expo *= 10)

counterSortDesc(array, n, expo);

}

// print an max

void print(int array[], int n)

{ cout<<"\n";

for (int i = 0; i < n; i++)

cout << array[i] << " ";

}

// Main function

int main()

{

int array[] = {185, 25, 35, 90, 904, 34, 2, 66};

int n = sizeof(array)/sizeof(array[0]);

radixsort(array , n);

print(array, n);

radixsortDesc(array,n);

print(array,n);

return 0;

}

Explanation:

You might be interested in
Let S = { p q |p, q are prime numbers greater than 0} and E = {0, −2, 2, −4, 4, −6, 6, · · · } be the set of even integers. . Pr
Finger [1]

Answer:

prove that | S | = | E | ; every element of S there is an Image on E , while not every element on E has an image on S

Explanation:

Given that S = { p q |p, q are prime numbers greater than 0}

                    E = {0, −2, 2, −4, 4, −6, 6, · · · }

To prove  by constructing a bijection from S to E

detailed  solution attached below

After the bijection :

<em>prove that | S | = | E |</em> :  every element of S there is an Image on E , while not every element on E has an image on S

∴ we can say sets E and S are infinite sets

7 0
3 years ago
___________ is NOT a common injury that an automotive tech may experience at work.
Degger [83]

Answer:The most common injuries were sprains/strains (39% of the total), lacerations (22%), and contusions (15%). Forty-nine percent of the injuries resulted in one or more lost or restricted workdays; 25% resulted in 7 or more lost or restricted workdays.

Explanation:

The most common injuries were sprains/strains (39% of the total), lacerations (22%), and contusions (15%). Forty-nine percent of the injuries resulted in one or more lost or restricted workdays; 25% resulted in 7 or more lost or restricted workdays.

7 0
3 years ago
What are three demonstration drive tips for the vc-turbo engine?.
Oliga [24]

The three (3) demonstration drive tips for a VC-turbo engine are:

  1. Use your gears when overtaking and driving up a long hill.
  2. Warm up your engine before accelerating.
  3. Ensure your oil level is at the optimum gauge or level.

<h3>What is a VC-turbo engine?</h3>

A VC-turbo engine can be defined as a technologically-advanced internal combustion engine that is design and developed to be faster, especially by combining the torque and efficiency of an advanced diesel powertrain with the power of a high-performance gas engine.

<h3>The demonstration drive tips.</h3>

Basically, the three (3) demonstration drive tips for a VC-turbo engine include the following:

  1. Use your gears when overtaking and driving up a long hill.
  2. Warm up your engine before accelerating.
  3. Ensure your oil level is at the optimum gauge or level.

Read more on drive tips here: brainly.com/question/23968178

4 0
3 years ago
Suppose an underground storage tank has been leaking for many years, contaminating a groundwater and causing a contaminant conce
Ghella [55]

Answer: the cancer risk for an adult male drinking the water for 10 years is 2.88 × 10⁻⁶

Explanation:

firstly, we find the time t required to travel for the contaminant to the well;

Given that, contamination flowing rate = 0.5 ft/day

Distance of well from the site = 1 mile =  5280 ft

so t = 5280 / 0.5 = 10560 days

k is given as 1.94 x 10⁻⁴ 1/day

next we find the Pollutant concentration Ct in the well

Ct = C₀ × e^-( 1.94 x 10⁻⁴ × 10560)

Ct = 0.3 x e^-(kt)  

Ct= 0.0386 mg/L

next we determine the chronic daily intake, CDI

CDI =  (C x CR x EF x ED) / (BW x AT)

where C is average concentration of the contaminant(0.0368mg/L), CR is contact rate (2L/day), EF is exposure frequency (350days/Year), ED is exposure duration (10 years), BW is average body weight (70kg).

now we substitute  

CDI = (0.0368 x 2 x 350 x 10) / ((70x 365) x 70)

= 257.7 / 1788500

= 0.000144 mg/Kg.day

CDI = 1.44 x 10⁻⁴ mg/kg.day  

Finally we calculate the cancer risk, R

Slope factor SF is given as 0.02 Kg.day/mg

Risk, R = I x SF

= 1.44 x 10⁻⁴ mg/kg.day  x 0.02Kg.day/mg    

R = 2.88 × 10⁻⁶

therefore the cancer risk for an adult male drinking the water for 10 years is 2.88 × 10⁻⁶

7 0
3 years ago
What is the standard half-cell potential for the oxidation of methane under acidic conditions? The reaction for methane is as fo
Yuri [45]

Answer:

The element that is oxidized is carbon.

Its oxidation state increased. It increased from -4 to +4

Explanation:

Oxidation is a process that involves increase in oxidation number.

The oxidation number of carbon in CH4 is -4

C + (1×4) = 0

C + 4 = 0

C = 0 - 4 = -4

The oxidation number of carbon in CO2 is +4

C + (2×-2) = 0

C - 4 = 0

C = 0+4 = 4

Increase in the oxidation number of carbon from -4 to +4 means carbon is oxidized

4 0
3 years ago
Other questions:
  • A structure that extends from a bridge to<br>form a firm foundation​
    6·2 answers
  • A four-cylinder, four-stroke spark-ignition engine operates at 2800 RPM. The processes within each cylinder can be modeled as an
    14·1 answer
  • The statement that is NOT true about the difference between laminar and turbulent boundary layers is:1.the Reynolds number for a
    8·1 answer
  • Determine an expression in standard form for the voltage gain VoVs. Hv(jω)=Vo(jω)Vi(jω)=R2R111+jωCR2 Hv(jω)=Vo(jω)Vi(jω)=−R2R111
    15·1 answer
  • Air (ideal gas) is contained in a cylinder/piston assembly at a pressure of 150 kPa and a temperature of 127°C. Assume that the
    12·1 answer
  • 5. If a pilot wants to accelerate, which force
    13·1 answer
  • A water contains 50.40 mg/L as CaCO3 of carbon dioxide, 190.00 mg/L as CaCO3 of Ca2 and 55.00 mg/L as CaCO3 of Mg2 . All of the
    5·2 answers
  • A continuously variable transmission:
    13·1 answer
  • What type of diagrams are used to present the conditions that are available to control outputs based on inputs?
    5·1 answer
  • Using data in Appendix A ,calculate the number of atoms in 1 tonne of iron
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!