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
Write the definition of a function named averager that receives a double parameter and return-- as a double -- the average value
lys-0071 [83]

Answer:

Following are the definition of function  

double averager (const double &x)  // function definition

{

static double z = 0.0;  // variable declaration

static size_t c = 0;

 c=c+1;  // increment of c by 1

z =z+ x;  // adding value  

return z /c ;   // return average  

}

Explanation:

Following are the description of statement  

  • Create a function averager of double type that holds a parameter "x" of the double type .
  • In this function we declared a variable "z" of a static double type that value is initialized by 0.
  • The static variable is used to retain value.
  • Declared a variable "c" of size_t type that holds a value 0 .
  • After that increment the value of c by 1 .
  • adding the value of "z" variable to the "x" and storing the result into the z variable.
  • Finally return the average value  
4 0
3 years ago
You are looking at a standard english ruler divided into eighths. If an item
Goryan [66]

Answer:

1)Measure with a ruler or tape measure. ...

2)Place the zero end of your rule at the end of your object. ...

3)Move to the opposite side of the object you are measuring. ...

4))Use a metric or decimal rule with a metric ruler. ...

5)Use a tape measure to measure between objects, for instance, walls.

Explanation:

A ruler marked in 16ths. Every mark is 1/16th of an inch. The center mark between numbers is 1/2. The red lines on these rulers are marked at 1/2, and 1. The next smallest marks on a ruler are 1/4ths.

7 0
3 years ago
Write a script called checkLetter.sh Review Greeting.sh for an example. Use a read statement and ask user to "Enter A, B, or C:
Artist 52 [7]

Answer:

The code is given as below: The input and output is as given for one case.

Explanation:

echo -e "Enter A, B or C : \c" #Printing the line on the screen

read -rN 1 test #read the character in the variable test

echo

case $test in #Setting up the case structure for variable test

[[:lower:]] ) #checking all lower case letters

echo You did not enter A, B or C;;

[D-Z] ) #checking upper case letters from D to Z

echo You did not enter A, B or C;;

A ) #Condition to check A

echo You entered A;;

B ) #Condition to check B

echo You entered B;;

C ) #Condition to check C

echo You entered C;;

esac #Exiting the case structure

7 0
4 years ago
Find the different pup
Nastasia [14]
What’s the question?
6 0
3 years ago
Which of the following is considered true regarding the future of technology?
netineya [11]
Hello!

The answer is:
-It is evolving quickly and always changing.

I hope that this helps you!
5 0
3 years ago
Other questions:
  • Suppose you are the security manager of a company and one of your goals is to design security mechanisms based on three security
    10·1 answer
  • Give two reasons why it is important to upgrade your browser when a new version becomes available.
    8·1 answer
  • Why is it preferable to code web pages in HTML format?
    7·1 answer
  • Which of the following was one of the first internet search engines? A. archie B. google C. Yahoo D.ask
    7·1 answer
  • Does a wizard function allow the user to enter or modify data in the records? select yes or no
    5·1 answer
  • PLZ HELPPPPPPPPPPPPPPPPPPPP
    9·1 answer
  • What do rocket scientists mean when they say, "forces come in pairs?"
    7·1 answer
  • This is your data.
    11·2 answers
  • How do we calculate the BMI in python? <br> the formula is kg/m²
    12·1 answer
  • Here, Do this for 100 points its simple just know how to use flowchart
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!