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 Asch’s study which of these lowered conformity rates
skad [1K]

Answer:

D. all of these are correct

Explanation:

option d is correct answer

3 0
3 years ago
Read 2 more answers
who likes tom holland as spiderman and his web shooter tippets when he swings off buildings in new york city midtown, Forest Hil
S_A_V [24]

Answer:

YESSSS!!!!

Explanation:

5 0
3 years ago
Read 2 more answers
What is meant by usability and what characteristics of an interface are used to assess a system’s usability?
ahrayia [7]

Answer:

The answer is below

Explanation:

Usability is a term that describes the assessment of the performance of a system in assisting the task of the user, or how effective a certain product system or design supports the task of a user in accomplishing a set out objective as desired.

The characteristics of an interface that are used to assess a system’s usability are:

1. Effectiveness

2. Efficiency

3. Error Tolerance

4. Engagement

5. Ease of Learning and Navigation

3 0
3 years ago
The ipv6 address fields are 128 bits long, and as such there is no need to extend ip addressing by using either dhcp or nat (i.e
Minchanka [31]

Answer:

True

Explanation:

according to coursehero it's true

6 0
2 years ago
What file format is best to give a printer when working with Adobe InDesign?
qwelly [4]

Answer:

TIFF

Explanation:

GIFs are animated image files, and printers can't print animations

TIFFs are basically image files

HTML is a coding file, you were to print it, it would print the HTML text of the image

IDML is an XML representation of an InDesign document or components, if you were to print it, its outcome would be basically the same as printing an HTML file.

7 0
3 years ago
Other questions:
  • You have been given two classes, a Main.java and a Coin.java. The coin class represents a coin. Any object made from it will hav
    13·1 answer
  • Under the advanced options screen, what startup option should be enabled in order to view what did and did not load during the b
    12·1 answer
  • Which business document is usually written in block style with the body tedt aligned along its left margin?
    9·1 answer
  • Which statement are true regarding mainframe computers
    13·1 answer
  • In computer science, what are two names that are used to describe data structures organized by association
    6·1 answer
  • Create a winform application that lets the user enter a temperature. With a ComboBox object offer the user three choices for inp
    9·1 answer
  • Which of the following is true of a procedure? Check all that apply.
    10·2 answers
  • State differences between title bar and menu bar​
    5·1 answer
  • Create a simple program of your own using a Loop that counts and displays numbers 1-10.
    12·1 answer
  • What are 3 key factors in defining cost on cloud storage
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!