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
natka813 [3]
3 years ago
9

Write a void function SelectionSortDescendTrace() that takes an integer array, and sorts the array into descending order. The fu

nction should use nested loops and output the array after each iteration of the outer loop, thus outputting the array N-1 times (where N is the size). Complete main() to read in a list of up to 10 positive integers (ending in -1) and then call the SelectionSortDescendTrace() function.
If the input is:

20 10 30 40 -1
then the output is:

40 10 30 20
40 30 10 20
40 30 20 10
Computers and Technology
1 answer:
salantis [7]3 years ago
8 0

Answer:

See explaination

Explanation:

#include <iostream>

using namespace std;

void SelectionSortDescendTrace(int numbers[], int numElems) {

int maxInd;

for (int i = 0; i < numElems - 1; ++i) {

maxInd = i;

for (int j = i; j < numElems; ++j) {

if (numbers[j] > numbers[maxInd]) {

maxInd = j;

}

}

int temp = numbers[i];

numbers[i] = numbers[maxInd];

numbers[maxInd] = temp;

for (int j = 0; j < numElems; j++) {

cout << numbers[j] << " ";

}

cout << endl;

}

}

int main() {

int numbers[10];

int numElements = 0;

for (int i = 0; i < 10; i++) {

cin >> numbers[i];

if (numbers[i] == -1)

break;

++numElements;

}

SelectionSortDescendTrace(numbers, numElements);

return 0;

}

You might be interested in
Jacob is a teacher and wants to sort his grades based on Test 1 and then on Test 2.
Pachacha [2.7K]
<span>He would click on the Test 1 column and press Sort, then click on the Test 2 column and press Sort. 
 It depends on what you learn because it says "shift"</span>
4 0
3 years ago
Read 2 more answers
2. Consider a 2 GHz processor where two important programs, A and B, take one second each to execute. Each program has a CPI of
allsm [11]

Answer:

program A runs in 1 sec in the original processor and 0.88 sec in the new processor.

So, the new processor out-perform the original processor on program A.

Program B runs in 1 sec in the original processor and 1.12 sec in the new processor.

So, the original processor is better then the new processor for program B.

Explanation:

Finding number of instructions in A and B using time taken by the original processor :

The clock speed of the original processor is 2 GHz.

which means each clock takes, 1/clockspeed

= 1 / 2GH = 0.5ns

Now, the CPI for this processor is 1.5 for both programs A and B. therefore each instruction takes 1.5 clock cycles.

Let's say there are n instructions in each program.

therefore time taken to execute n instructions

= n * CPI * cycletime = n * 1.5 * 0.5ns

from the question, each program takes 1 sec to execute in the original processor.

therefore

n * 1.5 * 0.5ns = 1sec

n = 1.3333 * 10^9

So, number of instructions in each program is 1.3333 * 10^9

the new processor :

The cycle time for the new processor is 0.6 ns.

Time taken by program A = time taken to execute n instructions

=  n * CPI * cycletime

= 1.3333 * 10^9 * 1.1 * 0.6ns

= 0.88 sec

Time taken by program B = time taken to execute n instructions

= n * CPI * cycletime

= 1.3333 * 10^9 * 1.4 * 0.6

= 1.12 sec

Now, program A runs in 1 sec in the original processor and 0.88 sec in the new processor.

So, the new processor out-perform the original processor on program A.

Program B runs in 1 sec in the original processor and 1.12 sec in the new processor.

So, the original processor is better then the new processor for program B.

5 0
2 years ago
ISDN stands for Internet Services Dynamic Network True/False
aev [14]

The answer is the second option "false." ISDN does not stand for Internet Services Dynamic Network it stands for Integrated Services Digital Network. ISDN is the international communication center for sending data, video, and voice over telephone wires.

Hope this helps.

7 0
3 years ago
Technology trends in education play a key role in a student’s: social life. motivation. career readiness. job search.
skelet666 [1.2K]

Answer:

job search

Explanation:

job search bc you can look for jobs that are avalible online.

4 0
2 years ago
Read 2 more answers
Whose work is responsible for the invention of the air bag? Scientist, Engineers or both?
jenyasd209 [6]

The scientist and the engineers were both responsible for the invention of the airbag.

  • Peter Florhancicn was a scientist and he invented the airbag because of the Dutch people who drowned when they drove into the canals

  • Also, John Hetrick who was an engineer filed for the patent of airbags when he saw that deers were running across the road. He believed that it could cause an accidentthat led to the invention.

In conclusion, both the engineers and the scientists were responsible.

Read related link on:

brainly.com/question/24686827

3 0
2 years ago
Other questions:
  • Computer hardware without computer software is useless while computer software without computer hardware is meaningless. Discuss
    10·1 answer
  • . Suppose that name is a variable of type string. Write the input statement to read and store the input Brenda Clinton in name
    5·1 answer
  • What is the major benefit Smartphones and tablet computers have had on social media?
    9·1 answer
  • _____ should be used to create a project schedule.
    14·1 answer
  • High level language - An object oriented programming language​
    5·1 answer
  • Create a file named homework_instructions.txt using VI editor and type in it all the submission instructions from page1 of this
    7·1 answer
  • Write a program named split_me.py that accepts a string in the format Age.FirstName and returns the value FirstName is Age years
    14·1 answer
  • Why can it be helpful to perform mathematical calculations using programming? Choose the best answer.
    11·1 answer
  • Where can formatting features be found ?! Need help asp !‍♀️
    9·1 answer
  • What is pollution?
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!