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
For each of the resistors shown below, use Ohm's law to calculate the unknown quantity, Be sure to put your answer in proper eng
daser333 [38]

Answer:

the hurts my brain sorry bud cant help

Explanation:

6 0
3 years ago
Driving Distraction Brainstorming Session
Leto [7]

texting, phone calls, putting on makeup, brushing hair, movies playing in car, loud music, children, and that's pretty much all I could think of

please give <u>BRAINLIEST ANSWER └[T‸T]┘</u>

5 0
3 years ago
Define extensive and intensive properties of thermodynamic system.
Flura [38]

Answer:

An intense property is a physical attribute of a system that is independent of the size of the system or the quantity of material it contains. An extensive property of a system, on the other hand, is dependent on the size of the system or the amount of material in it.

Explanation:

7 0
3 years ago
Read 2 more answers
Compressed Air In a piston-cylinder device, 10 gr of air is compressed isentropically. The air is initially at 27 °C and 110 kPa
Helen [10]

Answer:

(a) 2.39 MPa (b) 3.03 kJ (c) 3.035 kJ

Explanation:

Solution

Recall that:

A 10 gr of air is compressed isentropically

The initial air is at = 27 °C, 110 kPa

After compression air is at = a450 °C

For air,  R=287 J/kg.K

cv = 716.5 J/kg.K

y = 1.4

Now,

(a) W efind the pressure on [MPa]

Thus,

T₂/T₁ = (p₂/p₁)^r-1/r

=(450 + 273)/27 + 273) =

=(p₂/110) ^0.4/1.4

p₂ becomes  2390.3 kPa

So, p₂ = 2.39 MPa

(b) For the increase in total internal energy, is given below:

ΔU = mCv (T₂ - T₁)

=(10/100) (716.5) (450 -27)

ΔU =3030 J

ΔU =3.03 kJ

(c) The next step is to find the total work needed in kJ

ΔW = mR ( (T₂ - T₁) / k- 1

(10/100) (287) (450 -27)/1.4 -1

ΔW = 3035 J

Hence, the total work required is = 3.035 kJ

4 0
3 years ago
If your accelerator pedal gets stuck, what is the first thing you should do?
Anna35 [415]

If your accelerator gets stuck down, do the following: Shift to neutral. Apply the brakes. Keep your eyes on the road and look for a way out.If your accelerator gets stuck down, do the following:

Shift to neutral.

Apply the brakes.

Keep your eyes on the road and look for a way out.

Warn other drivers by blinking and flashing your hazard lights.

Try to drive the car safely off the road.

Turn off the ignition when you no longer need to change direction.

8 0
3 years ago
Other questions:
  • Work-producing devices that operate on reversible processes deliver the most work, and work-consuming devices that operate on re
    6·1 answer
  • Consider a system with two tasks, Task1 and Task2. Task1 has a period of 200 ms, and Task2 has a period of 300 ms. All tasks ini
    5·1 answer
  • A satellite is launched 600 km from the surface of the earth, with an initial velocity of 8333.3 m./s, acting parallel to the ta
    14·1 answer
  • ). A company periodically tests its product for tread wear under simulated conditions. Thirty random samples, each containing 5
    11·1 answer
  • A hollow pipe is submerged in a stream of water so that the length of the pipe is parallel to the velocity of the water. If the
    9·1 answer
  • If a car travels 8 miles in 15 minutes, what is the speed of the car in miles per hour
    11·1 answer
  • Please help i will give brainilest
    12·2 answers
  • 1. Which of these materials is the strongest?
    12·1 answer
  • (Architecture) Sarah is an environmental activist. She frequently conducts various programs and activities in her community to p
    15·1 answer
  • What is the difference between absorbed wavelengths and reflected wavelengths?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!