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
Cast iron has about how much carbon content?
Aliun [14]

Answer:

c

Explanation:

7 0
2 years ago
A force is a push or pull in A.a circle B.an arc C.a straight line
Bingel [31]

Answer:

I think it is B: an arc

Explanation:

hope this helps mark as brainiest

4 0
3 years ago
Which permission do you need to shoot on the owner’s property?
Elena L [17]

Answer:

filming permit,

( MARK ME BRAINLIEST!!)

4 0
2 years ago
You don't know which insert you have, and the inserts are different sizes, meaning the amount needed for a 1:3 ratio is differen
VashaNatasha [74]

Answer:

Explanation:

For ligation process the 1:3 vector to insert ratio is the good to utilize . By considering that we can take 1 ratio of vector and 3 ratio of insert ( consider different insert size ) and take 10 different vials of ligation ( each calculated using different insert size from low to high ) and plot a graph for transformation efficiency and using optimum transformation efficiency we can find out the insert size.

6 0
3 years ago
Georgia Tech is committed to creating solutions to some of the world’s most pressing challenges. Tell us how you have improved o
Kaylis [27]

Answer:

Georgia Tech is committed to WGAR 53566 THE ANSWER IS JELLY IS KING AND THE JELLY IS KING AND  hope to improve the human condition in your community.

Explanation:

6 0
3 years ago
Other questions:
  • Which type of door consists of thin pieces of wood, glass, or louvers placed within a framed rectangular area?
    7·2 answers
  • If the 1550-lb boom AB, the 190-lb cage BCD, and the 169-lb man have centers of gravity located at points G1, G2 and G3, respect
    11·1 answer
  • Project 8:The Harris-Benedict equation estimates the number of calories your body needs to maintain your weight if you do no exe
    5·1 answer
  • What did the ancient Greeks use simple machines for?
    15·2 answers
  • A 2.5 m wide rough continuous foundation is placed in the ground at 1 m depth. There is bedrock present at 1 m depth below the b
    12·1 answer
  • Is the MI-24 Hind the most widely exported combat helicopter in the world?
    14·1 answer
  • Work to be performed can come from the work package level of the work breakdown structure as well as other sources. Which of the
    11·1 answer
  • Using the tables for water, determine the specified property data at the indicated states. In each case, locate the state on ske
    10·1 answer
  • This acronym is a reminder of the most common types of hazards or injuries caused by electricity.
    14·1 answer
  • 11. What are restrictions when building or completing a challenge?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!