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
In three or four sentences, describe how a person buys and sells stock.
Aleksandr-060686 [28]
In order to buy stock, you must go and find a stock broker. You do not always need a broker, but it is more convenient to have one to manage your stock. It also makes your life in the market easier. The broker will manage your shares and you tell him when you want to buy or sell your stock.
4 0
2 years ago
Read 2 more answers
A _ is the acknowledgment of a potential noncomformity, or an opinion regarding an issue that is not covered by a standard
sleet_krkn [62]
Assumption - hope this helped took the test and got 100
5 0
2 years ago
you have been tasked with configuring a digital information station in the office's lobby. guests will be able to use the statio
REY [17]

The most important security consideration for the station is code signing. With code signing, consumers may feel confident about the software they are downloading and can stop worrying about infecting their computer.

With code signing, consumers may feel confident about the software they are downloading and can stop worrying about infecting their computer or mobile device with malware. Code signing has grown in importance for software developers and distributors as more software may be downloaded from the Internet.

Malware can be easily installed on a victim's computer by an attacker who poses as a trustworthy source. As long as users only download software that is regarded as safe by their operating system, code signing ensures that these types of assaults cannot happen.

Nowadays, the Operating System looks for the digital certificate produced through code signing when software is downloaded onto a computer to ensure the security of the software being installed. The user is informed and given the option to stop or continue the installation if no digital certificate is detected.

To know more about code signing click here:

brainly.com/question/28860592

#SPJ4

3 0
8 months ago
SOMEONE PLEASE HELP ME I REPOSTED THIS 3 time and no ONE HAD HELPED ME
RoseWind [281]

Answer:

The answer is B

7 0
3 years ago
Office ____ is the current version of Microsoft Office for Mac operating systems.
gregori [183]

The current version of office is "Office 19" most people use "Office 365" though.

A "Pdf" or "Portable Document Format."

4 0
2 years ago
Other questions:
  • Computers are said to use binary data because all computer data is simply a series of Os and 1s.
    10·1 answer
  • Talking to a friend _____.
    5·2 answers
  • What are 3 websites that talk about density of different gases, density in air, behavior of different gases of earth, convection
    13·1 answer
  • In order to make burger a chef needs the following ingredients one piece of chicken meat 3 lettuce leaves 6 tomato slices Write
    8·1 answer
  • Nate wants to copy the style of his contact address to the normal template. Complete the paragraph to describe how he can access
    12·2 answers
  • ANSWER ASAP!!!!!
    10·2 answers
  • The command to get out of the loop.<br>a.<br>i exit<br>ii. break<br>iii. comment<br>iv. for​
    12·1 answer
  • (20points)
    6·1 answer
  • Rosa is building a website for a multimedia company. She wants to add a drop-down menu functionality to the website's main page.
    12·1 answer
  • Which of the following is NOT one of the three main ways to control a program when writing code?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!