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
MaRussiya [10]
3 years ago
11

2.2-2 Consider sorting numbers stored in array by first finding the smallest element n A of and exchanging it with the element i

n . Then find the second smallest A AOE1 element of A, and exchange it with . Continue in this manner for the firs AOE2 1 elements of A. Write pseudocode for this algorithm, which is known as selection sort. What loop invariant does this algorithm maintain? Why does it need to run for only the firs elements, rather than for all elements? Give the best-case n 1 n and worst-case running times of selection sort in ‚-notation.
Computers and Technology
1 answer:
True [87]3 years ago
7 0

Answer:

Follows are the explanation of the choices:

Explanation:

Following are the Pseudocode for selection sort:                      

for j = 0 to k-1 do:

      SS = i

      For l = i + 1 to k-1 do:

        If X(l) < X(SS)

          SS= l

        End-If

      End-For

      T = X(j)

      X(j) = X(SS)

      X(SS) = T

    End-For

Following are the description of Loop invariants:

The subarray  A[1..j−1] includes the lowest of the j−1 components, ordered into a non-decreasing order, only at beginning of the iteration of its outer for loop.  

A[min] is the least amount in subarray A[j.. l−1] only at beginning of the each loop-inner iterations.                      

Following are the explanation for third question:

Throughout the final step, two elements were left to evaluate their algorithm. Its smaller in A[k-1] would be placed as well as the larger in A[k]. One last is the large and medium component of its sequence because most and the last two components an outer loop invariant has been filtered by the previous version. When we do this n times, its end is a repetitive, one element-sorting phase.

Following is the description of choosing best-case and worst-case in run- time:

The body the if has never been activated whenever the best case time is the list is resolved. This number of transactions are especially in comparison also as a procedure, that will be (n-1)(((n+2)/2)+4).    

A structure iterator at every point in the worst case that array is reversed, that doubles its sequence of iterations in the inner loop, that is:(n−1)(n+6) Since both of them take timeΘ(n2).

You might be interested in
Order the steps to use a logical argument as a rule type.
muminat

Answer:

Click home tab, click conditional formatting, click new rule, use formula to determine

6 0
2 years ago
Read 2 more answers
Write a function, named "wait_die_scheduler" that takes a list of actions, and returns a list of actions according to the follow
lidiya [134]

Answer:

See attached picture for complete code.

Explanation:

See attached picture.

4 0
2 years ago
A computer on a network that is not the server​
katrin [286]

Answer:

A peer-to-peer network is one in which two or more PCs share files and access to devices such as printers without requiring a separate server computer or server software. ... A P2P network can be an ad hoc connection—a couple of computers connected via a Universal Serial Bus to transfer files.

5 0
2 years ago
Complete the program by writing and calling a function that converts a temperature from Celsius into Fahrenheit. Use the formula
Rina8888 [55]

Answer:

C = int(input("Enter a number ::))

F = (C * (9 /5)) + 32

print(" {} in Fahrenheit is {} ". format(C, F))

Explanation:

The program takes an input from the user and converts the input to a fahrenheit.

4 0
3 years ago
What is the term for the part of a browser responsible for reading and processing programming languages?
koban [17]
The interpreter is the answer.
4 0
3 years ago
Other questions:
  • 1. Why is it important to compare features of a computer before making a purchase?
    13·2 answers
  • The lightbulb transfers electricity energy into light what is one type of energy that is also generated that is not a desired af
    14·1 answer
  • Create a program to calculate the wage. Assume people are paid double time for hours over 60 a week. Therefore they get paid for
    10·1 answer
  • Web browsers are used to browse the world wide web.
    5·2 answers
  • Explain the importance of mobile computing in communication​
    7·2 answers
  • When comparing different biometric systems, one of the most important metrics used is called the _________, which represents the
    14·1 answer
  • A wireless network does not benefit like a wired network does, when it comes to collision reduction. Which device reduces collis
    6·1 answer
  • What types of tools are used in the process of a digital or network investigation?
    12·1 answer
  • Software that was designed to serve the needs of a specific company or organization is called:
    11·1 answer
  • Explain different types of networking-based attacks
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!