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
What is earning potential?
Natalka [10]

Answer:

Earning potential often refers to the top salary for a particular field or profession. In the finance world, the meaning is not much different: earning potential is the biggest profit a company could potentially make.

Explanation:

Earning potential often refers to the top salary for a particular field or profession. In the finance world, the meaning is not much different: earning potential is the biggest profit a company could potentially make.

4 0
3 years ago
I need help picture above
sammy [17]

Answer:

True

Explanation:

hoped I helped Im Eve btw Have a great day and consider marking this brainliest if you do thank you in advanced!

6 0
3 years ago
Read 2 more answers
Which of the following statements is true?
Lilit [14]

Answer:

Option A is the correct answer choice for the above question.

Explanation:

The computer system needs intercommunication which is done inside the processor to process the task given by the user. There are two types of model is used for intercommunication--

  1. Message passing and
  2. Shared memory

The difference between two is that message passing passes the message on two points at a single unit of time whereas shared memory simultaneous shares the multiple messages. That's why shared memory is faster than message passing.

  • Hence option A is the correct choice because it also refers to the above concept. While the other is not correct because--
  • Option B states that message passing is faster than shared memory which is wrong.  
  • Option C states that message passing is used for large data but shared memory is used for large data.
  • Option D states that shared memory is unavailable in some processor which is wrong.
3 0
3 years ago
Hello safiya77 this is for you
Ray Of Light [21]
Hello astropiggy!
Feel free to ask any question!
I’ll try my best to answer them!
5 0
2 years ago
A user wants to visualize a highly complex 3D model using a Virtual Reality headset.
Lyrx [107]

The best way for an end user to visualize a highly complex 3D model using a Virtual Reality headset is to: A) use any headset and increase the bandwidth of the Wi-Fi connection.

<h3>What is Virtual Reality (VR)?</h3>

Virtual Reality (VR) can be defined as a computer technology through which virtual images of any physical environment (realities) and human-machine interactions are displayed, especially through the use of various computer technologies and wearables.

<h3>The elements of Virtual Reality (VR).</h3>

Some of the elements of Virtual Reality (VR) include the following:

  • Life interaction
  • Self projection
  • Telexistence
  • 3D space or model.

In this context, we can infer and logically deduce that Virtual reality is a  computer technology which is designed and developed to simulate a three-dimensional (3D) environment through which end users can explore and interact.

In conclusion, the best way for an end user to visualize a highly complex three-dimensional (3D) model using a Virtual Reality headset is to use any headset and increase the bandwidth of the Wi-Fi connection.

Read more on Virtual Reality here: brainly.com/question/26705841

#SPJ1

6 0
2 years ago
Other questions:
  • Privileged instructions 1) generate an interrupt so they can execute before non-privileged instructions. 2) are valid only when
    5·1 answer
  • Write a method that take an integer array as a parameter and returns the sum of positive odd numbers and sum of positive even nu
    13·1 answer
  • Implement the function pairSum that takes as parameters a list of distinct integers and a target value n and prints the indices
    11·1 answer
  • The principle of time preference requries a larger payment in the future than the present. Which situation best illustrates this
    12·1 answer
  • Write a program that declares a constant named QUARTS_IN_GALLON which holds the number of quarts in a gallon (4). Also declare a
    8·1 answer
  • What does IDLE stand for
    11·2 answers
  • Choose the true statement below. (html)
    5·1 answer
  • You are working on a ticketing system. A ticket costs $10. The office is running a discount campaign: each group of 5 people is
    5·1 answer
  • What is the answer ????​
    13·2 answers
  • WILL GIVE BRAINLIEST!!! PLEASE HELP!!!
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!