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
kumpel [21]
3 years ago
5

Write a function which sorts the queue in order from the smallest value to the largest value. This should be a modified version

of bubble sort.
Computers and Technology
1 answer:
PilotLPTM [1.2K]3 years ago
7 0

Answer:

#include <iostream>

using namespace std;

void swap(int *a,int *b){    //function to interchange values of 2 variables

   int temp=*a;

   *a=*b;

   *b=temp;

}

void sort(int queue[],int n)

{

   int i,j;

   for(i=0;i<n;i++)      //to implement bubble sort

   {

       for(j=0;j<n-i-1;j++)

       {

           if(queue[j]>queue[j+1])

               swap(queue[j],queue[j+1]);    //to swap values of these 2 variables

       }

   }

}

int main()

{

   int queue[]={6,4,2,9,5,1};

   int n=sizeof(queue)/4;  //to find length of array

   sort(queue,n);

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

       cout<<queue[i]<<" ";

   return 0;

}

OUTPUT :

1 2 4 5 6 9

Explanation:

In the above code, Queue is implemented using an array and then passed to a function sort, so that the queue can be sorted in ascending order. In the sort function, in each pass 2 adjacent values are compared and if lower index value is greater than the higher one they are swapped using a swap function that is created to interchange the values of 2 variables.

You might be interested in
Select the correct statement(s) regarding digital baseband modulation.
NeTakaya

Answer:

The answer is "Option d".

Explanation:

The electronic firmware synchronization was its method where even the series of bytes is amplified even before the transmission process into to the sound waves and, thus, and in conceptual "1s" and "0s" represented by large font, wavelengths, or switching frequency.

  • QAM utilizes both magnitudes of the transporter and adjustments in the phase shift.
  • Rational data is represented by \frac{\pi}{2} cartesian coordinates for both the carries waves of the same wavelengths and represents the result in total.
6 0
3 years ago
What refers to the processing of a substance or an object so that it may be used again?
Pavel [41]

Answer:

recycling is the answer

8 0
2 years ago
Read 2 more answers
How many jobs can you get without a college degree
larisa86 [58]
The 10 highest-paying jobs you can get without a college degree all pay more than $79,000 those are Commercial pilots.
Detectives and criminal investigators. ...
Powerhouse, substation, and relay electrical and electronics repairers. ...
Elevator installers and repairers. ...
Power plant operators. ...
Media and communication equipment workers. ...
7 0
3 years ago
Read 2 more answers
Int [] val = { 3, 10, 44 };
irina1246 [14]

Answer:

5) 3 0 0

Explanation:

Given data

int [] val = { 3, 10, 44 };

The total number of parameters of given array are 3, so total length of array is also 3.

The indexing of array starts with '0', Therefore the indexes of array with length zero are: {0,1,2}

The value of array at index 0 is = 3

similarly

value at index 1 = 10

value at index 2 = 44

Here, Int i = 1 is storing the value '1' in integer variable i.

In addition to that, any value of index 'i' of an array is selected using array[i].

Therefore,

val[i] = i-1 is copying the value (i-1 = 1-1 = 0) to the index '1'  of the array because i = 1.

So value at index 1 would be = val[1] = 0

The term i++ is incrementing the value of i, it makes i =2

val[i] = i-1 is copying the value (i-1 = 1-1 = 0) to the index '2' of the array because i = 2 now.

So value at index 2 would be = val[2] = 0

Hence, the output would be {3 0 0}. So 5th option is correct.

4 0
2 years ago
Can i add ADSence on bangla content in blogsopt website?
Inga [223]

Answer:

I do not think you can! However, I am not sure since I mainly use Wix!!!

Explanation:

8 0
3 years ago
Other questions:
  • The times per second an audio file is converted from analog to digital is the ______. audio file format bandwidth sample rate wa
    5·2 answers
  • Get these points why they hot!!!!!!!!!!!!!!!!!!!!
    14·2 answers
  • ⭐️⭐️⭐️ what Network is larger in size? MAN or WAN? Thank you ⭐️⭐️⭐️
    5·1 answer
  • Which director has shot a movie in HD? George Lucas, Michael Mann, Michael Moore, none of the above, all of the above
    14·1 answer
  • What is an example of a transition effectl
    7·1 answer
  • in Python we use IDE ( lntegrated Dvelopment Environment ) to write down the program data points of difference between script mo
    13·1 answer
  • Dominic list his camera for sale on an online auction site Chloe is the highest bitter and purchase as the camera how does the a
    14·1 answer
  • Which tool can effectively increase the curl of the subject’s lips?
    10·2 answers
  • True or false scientists investigate and seek to explain the natural world
    14·1 answer
  • It is important to consider design details when creating an api because: ______________
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!