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
Location of a video or photoshoot is not important when it comes to preplanning the shoot
faust18 [17]

Answer: Location of a video or photoshoot is not important when it comes to preplanning the shoot. 2. Booms are large adjustable poles to mount microphones.

3 0
3 years ago
In which network zone should a web server be placed?
Cloud [144]

Answer:

DMZs

Explanation:

"That's fine for a small company, but a larger company should consider creating a perimeter security network called a demilitarized zone (DMZ) that separates the internal network from the outside world. DMZs are the best place for your public information."

       - ZDNetwww.zdnet.com › article › dmzs-for-dummies-5000297743

7 0
3 years ago
Aisha designed a web site for her school FBLA club and tested it to see how well it would resize on different systems and device
VARVARA [1.3K]

Answer: responsive

Explanation:

its called mobile responsivness and most good websites have it

5 0
2 years ago
A material systems developer typically combines the skills of a programmer with the multitasking expectations of a
shusha [124]

Explanation:

Material systems developer typically combines the skills of a programmer with the multitasking expectations of developing 3 dimensional models of objects, enhancing the graphical effects.

don't delete my answer this time i try to help ppl

3 0
3 years ago
What country threatens Denmark at the beginning of Hamlet as evidenced in Marcellus’s question, "Why this same strict and most o
Ghella [55]

Answer: Norway is threatening Denmark

Explanation: Marcellus’s country is threatened with invasion by Norway as evidenced by Marcellus questions as to why Denmark is feverishly preparing for war.

6 0
4 years ago
Other questions:
  • When used as parameters, _________ variables allow a function to access the parameter’s
    10·1 answer
  • hardtack was a. a new cone-shaped bullet. c. a type of biscuit. b. a sharp turn made on command. d. a type of body armor.
    6·1 answer
  • Which of these automotive repair areas helps the vehicle change speeds to operate efficiently under all conditions?
    5·1 answer
  • Mrs. Johnson is here today to receive an intercostal nerve block to mitigate the debilitating pain of her malignancy. Her cancer
    13·1 answer
  • Retype the statements, correcting the syntax errors.
    8·1 answer
  • State and give reason, if the following variables are valid/invalid:
    12·1 answer
  • Which option is used in Access to locate and retrieve data that may be present in multiple database tables within the database?
    10·2 answers
  • A list contains the following items: Antelope, Baboon, Cheetah, Elephant, Giraffe, Hippo, Jackal, Lion, Okapi, Warthog. ​(a)​A b
    5·2 answers
  • Heyyyyyy<br> byeeeeeeeeeeeeeeeeeeeeeee
    15·2 answers
  • How to print something nad input on same line python
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!