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
A dielectric material, such as Teflon®, is placed between the plates of a parallel-plate capacitor without altering the structur
Lina20 [59]

Answer: The electric field decreases because of the insertion of the Teflon.

Explanation:

If the charge on the capacitor is held fixed, the electric field as a consequence of this charge distribution (directed from the positive charged plate to the negative charged one remains unchanged.

However, as the Teflon is a dielectric material, even though doesn't allow the free movement of the electrons as an answer to an applied electric field, it allows that the electrons be displaced from the equilibrium position, leaving a local negative-charged zone close to the posiitive plate of the capacitor, and an equal but opposite charged layer close to the negative plate.

In this way, a internal electric field is created, that opposes to the external one due to the capacitor, which overall effect is diminishing the total electric field, reducing the voltage between the plates, and  increasing the capacitance proportionally to the dielectric constant of the Teflon.  

8 0
3 years ago
Draw the internal connections of motor generator set​
Akimi4 [234]

Answer:

tyjtgfjhgk vgjyg7igjccxfb  rt5bshe dgrty5rm nry5ghbhjyrdegbtyr45bh4 cnbfgcb xdftjrnn hdftytr s  jhbgfhtyujt ntj

Explanation:

3 0
3 years ago
you have a permanent magnet whit remanent induction. than you cut a piec of that magnet. if you put that piece back into permane
ELEN [110]
Yes, it will. The induction will be the same as long as it’s put back together.
5 0
3 years ago
Draw perpendicular lines based on the info in the image.
Over [174]
Wait let me try it…..
5 0
3 years ago
Explain when it is appropriate to use Tier II?
garik1379 [7]

????? what do u mean tier 2

3 0
3 years ago
Other questions:
  • Is it more difficult to pump oil from a well on dry land or a well under water?Why?
    11·1 answer
  • Design a posttest-only experiment that would test each of the following causal claims. For each one, identify the study’s indepe
    13·1 answer
  • The distribution of actual weights of 8‑ounce wedges of cheddar cheese produced at a dairy is Normal, with mean 8.1 ounces and s
    5·1 answer
  • When you see a street with white markings only, what kind of street is it?
    7·1 answer
  • What is pneumatic troubleshooting
    6·1 answer
  • 6
    5·1 answer
  • How much energy in joule is added to a 12 g of sample of aluminum (c=0.897 J/g ◦C) to raise the temperature from 20 ◦C to 45 ◦C?
    14·1 answer
  • A 9 -slug mass hangs by a rope from the ceiling. Using the standard value of gravitational acceleration g = 32.2 fts 2, what is
    12·1 answer
  • PDC Bank is working on creating an AI application that enables customers to send SMS to the AI application to allow banking acti
    9·1 answer
  • How can the use of local materials improve the standard of living of Filipinos?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!