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
Troyanec [42]
3 years ago
10

Given an array of values which initially contains 9 8 7 6 5 4 3 2 1, what does the array look like after bubble sort has execute

d 3 passes, which means that the largest 3 values have been moved to their correct positions in the array.
Computers and Technology
1 answer:
Phantasy [73]3 years ago
7 0

Answer:

//Here is code in C++.

//include header

#include <bits/stdc++.h>

using namespace std;

// function to print the array

void out_arr(int inp[], int len)

{

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

 cout << inp[i] << " ";

cout << endl;

}

// main function

int main()

{

   // decalare and initialize the array

int inp[] = {9,8,7,6,5,4,3,2,1};

//find the length of array

int len = sizeof(inp)/sizeof(inp[0]);

int x, y;

// perform bubble sort, only 3 pass

for (x = 0; x < 3; x++)  

{

for (y= 0; y< len-x-1; y++)

 if (inp[y] > inp[y+1])

 {

  int t=inp[y];

  inp[y]=inp[y+1];

  inp[y+1]=t;

 }

 

 cout<<"array after "<<x+1<<" pass"<<endl;

 // print the array after every pass

     out_arr(inp, len);

}

return 0;

}

Explanation:

Declare an integer array "inp" and initialize with {9,8,7,6,5,4,3,2,1}. Find the length of the array.In first pass of bubble sort, largest value is placed at the correct position in the array. And in the second, second largest value is placed at its correct position. After the n pass, array will be sorted. In each pass, each element is compared with the next element. if the value is greater than swap them. This continues for all elements in each pass. In the end of a pass a value is placed correctly. So if there is only 3 pass then 3 largest values will be placed at their right place.

Output:

8 7 6 5 4 3 2 1 9                                                                                                              

array after 2 pass                                                                                                            

7 6 5 4 3 2 1 8 9                                                                                                              

array after 3 pass                                                                                                            

6 5 4 3 2 1 7 8 9

You might be interested in
We will pass in 2 values, X and Y. You should calculate XY XY and output only the final result. You will probably know that XY X
kiruha [24]

Answer:

import sys

# The value of the second argument is assigned to X

x = int(sys.argv[1])

# The value of the third argument is assigned to Y

y = int(sys.argv[2])

# The result of multiplication of x and y is assigned to 'result'

result = x * y

#The value of the result is displayed to the user

print("The result of multiplying ", x, "and ", y, "is", result)

Explanation:

First we import sys which allow us to read the argument passed when running the program. The argument is number starting from index 0; the name of the python file been executed is sys.argv[0] which is the first argument. The second argument is sys.argv[1] and the third argument is sys.argv[2].

The attached file is named multplyxy (it wasn't  saved as py file because the platform doesn't recognise py file); we can execute it by running: python3 multiplyxy.py 10 23

where x will be 10 and y will be 23.

To run the attached file; it content must be saved as a py file: multiplyxy.py

Download pdf
5 0
4 years ago
Draw the resistor’s voltage and current phasors at t=15ms. Draw the vectors with their tails at the origin. The orientation of y
NARA [144]

Answer: 22tm is the answer

Explanation:

7 0
4 years ago
Read 2 more answers
What are comments meant to do?
docker41 [41]
Comment<span> (computer programming) ... In computer programming, a </span>comment<span> is a programmer-readable explanation or annotation in the source code of a computer program. They are added with the purpose of making the source code easier for humans to understand, and are generally ignored by compilers and interpreters.</span>
8 0
3 years ago
Which of the selections below does not represent a workable ip address?
defon

Answer: C

Explanation:

Because ipv4 ip addresses will be 4 sets of numbers for a maximum of 255 per set ie.  The highest ipv4 number is 255.255.255.255 and the answer C has 293 in it.

6 0
4 years ago
What is the maximum duration of daily scrum meetings A:15minsB:45minsC10mins:30mins
scoray [572]

Answer:

A

Explanation:

A common approach to a daily scrum (although not the only approach) is for each member of the development team to address the following three daily scrum questions:

1. What did I accomplish since the last daily scrum?

2. What do I plan to work on by the next daily scrum?

3. What are the obstacles or impediments that are preventing me from making progress?

Development teams are typically between five to nine people. Each development team member should need no more than 90 seconds to address the three questions listed above. So, if you had a team of nine people, each of whom took 90 seconds to cover the questions, combined with some overhead of getting the meeting started and transitioning from person to person, you would end up with a meeting duration of about 15 minutes.

To emphasize that 15 minutes should be thought of as a timeboxed limit.

8 0
3 years ago
Read 2 more answers
Other questions:
  • What percentage of the global population of about seven billion people used the Internet in 2012?
    5·2 answers
  • Is a set of standards that define how email is to be processed between mail servers is exactly the same as smtp copies an e-mail
    10·1 answer
  • The picture that graphically represents the items you use in windows is called a/an
    15·2 answers
  • A network that typically reaches a few meters, such as up to 10 meters (33 feet), and consists of personal devices such as mobil
    14·1 answer
  • In a multiple-column record of a data file, ______ represent different variables and _______ represent different cases
    15·1 answer
  • Select three functions of the cell membrane.
    15·2 answers
  • PLEASE HELP 10 POINTS!!!Click this link to view O*NET’s Work Activities section for Human Resources Managers. Note that common a
    7·2 answers
  • The transmission control protocol (TCP) layer helps computers to communicate in which of the following ways?
    10·1 answer
  • Which validation method would you use for first name on a data form
    15·1 answer
  • 8. When “arc rated” clothing is worn it must allow for what
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!