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]
2 years ago
8

Using a queue.

Engineering
1 answer:
beks73 [17]2 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
Going back the b beginning of the process is common in engineering true or false?
Yuliya22 [10]

Answer:

true !!

Explanation:

hope i helped :)! brainliest ?

6 0
3 years ago
Which basic principle influences how all HVACR systems work?
bezimeni [28]

Answer:

B) An increase in pressure can lower the boiling point of a liquid and change the temperature at which it turns to a gas.

Explanation:

B) An increase in pressure can lower the boiling point of a liquid and change the temperature at which it turns to a gas.

6 0
3 years ago
Select the statement that is false.
ra1l [238]

Answer:

D

Explanation:

the way vertices are connected may be different so having same number of edges do not mean that total degree will also be same.

8 0
3 years ago
If there are 16 signal combinations (states) and a baud rate (number of signals/second) of 8000/second, how many bps could I sen
Mice21 [21]

Answer:

32000 bits/seconds

Explanation:

Given that :

there are 16  signal combinations (states) = 2⁴

bits  n = 4

and a baud rate (number of signals/second) = 8000/second

Therefore; the number of bits per seconds can be calculated as follows:

Number of bits per seconds = bits  n × number of signal per seconds

Number of bits per seconds =  4 × 8000/second

Number of bits per seconds = 32000 bits/seconds

6 0
2 years ago
It is appropriate to use the following yield or failure criterion for ductile materials (a) Maximum shear stress or Tresca crite
Nataly [62]

Answer:

(b)Distortion energy theory.

Explanation:

The best suitable theory for ductile material:

       (1)Maximum shear stress theory (Guest and Tresca theory)

It theory state that applied maximum shear stress should be less or equal to its maximum shear strength.

      (2)Maximum distortion energy theory(Von Mises henkey's        theory)

It states that maximum shear train energy per unit volume at any point  is equal to strain energy per unit volume under the state of uni axial stress condition.

But from these two Best theories ,suitable theory is distortion energy theory ,because it gives best suitable result for ductile material.

6 0
2 years ago
Other questions:
  • 7 Single-use earplugs require a professional fitting before they can be used.
    10·2 answers
  • Briefly describe the purpose of specifying boundary conditions.
    7·1 answer
  • A piston cylinder assembly fitted with a slowly rotating paddle wheel contains 0.13 kg of air at 300K. The air undergoes a const
    10·1 answer
  • Thermal conductivity of AISI 316 Stainless Steel at 90ºC is 14.54 W/m K. Convert this value to IP system.
    8·1 answer
  • An air conditioner using refrigerant-134a as the working fluid and operating on the ideal vapor-compression refrigeration cycle
    7·2 answers
  • Which option identifies the type of engineering technician most likely to be involved in the following scenario?
    9·1 answer
  • Describe two characteristics that bridges and skyscrapers have in common.
    10·1 answer
  • Somebody help me!! It’s due today
    9·1 answer
  • The image shows the relative positions of Earth and the Sun for each of the four seasons. Earth travels in an elliptical orbit a
    11·2 answers
  • Drivers education :Anything that draws your mind off driving is
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!