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]
4 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]4 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
What conversion factor should be used to convert from meters to Gigameters?
Anit [1.1K]
I have the equation 1 meter = 1.0 * 10
-9
5 0
4 years ago
What will be the best way for computer science students in Nepal for better salary .​
Nataly [62]

Answer:

The more knowledge you have of emerging trends, technologies and applications, the better suited you will be when it comes to applying for positions within the industry. According to Payscale, an average salary of students who have completed Bsc. Csit in Nepal is around Npr 5,00,000.

3 0
2 years ago
Which of the following rules need to be followed when using variables?<br> Choose all that apply.
Masja [62]

Answer:

- All variable names must begin with a letter of the alphabet or an. underscore( _ ).

-After the first initial letter, variable names can also contain letters and numbers.

-Uppercase characters are distinct from lowercase characters.

-You cannot use a C++ keyword as a variable name.

7 0
3 years ago
Read 2 more answers
Design and implement an application that uses dialog boxes to obtain two integer values (one dialog box for each value) and disp
dybincka [34]

Answer: hey

Explanation:

7 0
3 years ago
Style defines the hue of text characters. <br> True <br> False
Shalnov [3]
The correct answer is FALSE, style does not defines the hue of text characters.
4 0
4 years ago
Other questions:
  • Which two things will you see when you collapse the view of the subdocument in a master document? (Microsoft Word)
    8·2 answers
  • Which network component allows computers to communicate on a network without being connected directly to each other?
    9·1 answer
  • If you filmed a clip in 120fps, how many frames are in a seconds of video.
    13·1 answer
  • How do mentors provide professional development opportunities?
    8·2 answers
  • While in class you were introduced to the varieties
    7·1 answer
  • I'm getting pretty desperate plz help me, I'll give brainiest, and ill make a free question worth 100 points this is for coding
    10·1 answer
  • he wants to customize the operating system to meet his needs. what types of tools should he use, and what can he do with each?
    6·1 answer
  • - Discuss the input-process-output model as it relates to program development.
    12·1 answer
  • Need comments added to the following java code:
    6·1 answer
  • Which of the following is not a function of an operating system?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!