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
hodyreva [135]
4 years ago
13

Consider sorting n numbers stored in array A by first finding the smallest element of A and exchanging it with the element in A[

1]. Then find the second smallest element of A, and exchange it with A[2]. Continue in this manner for the first n − 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 first n − 1 elements, rather than for all n elements? Give the best–case and worst–case running times of selection sort in Θ–notation.
Computers and Technology
1 answer:
krek1111 [17]4 years ago
7 0

Answer:

1. create the first array A

2. create the second array A1, the same length as array A.

3. create a loop to iterate over both arrays for a number of times specific to the length of the arrays, with a condition to get and pop only the minimum value of which arrays for every loop.

4. save both items to "a" for minimum value A and "b" for minimum value A1.

5. call a function to push the "a" variable value to A1 and "b" variable value to the array A.

Explanation:

This code would interchange the values of both arrays, the best-case scenario for the code is O( n ) where n is the number of items in both arrays and worst is the best-case multiplied by the number of time to compare all the items with the minimum value.

You might be interested in
Alice has an item x and Bob has a set of five distinct items y1, y2, y3, y4 and y5. Design a protocol through which Alice (but n
lukranit [14]
I guess it will be 4 yards each hopes it will help u :)
4 0
2 years ago
Zack wants to be a landscape designer.which qualification would be best prepare him for work in this career
katen-ka-za [31]
Landscape design or landscape horticulture. a bachelor degree for these.
4 0
3 years ago
Read 2 more answers
4.5 code practice edhesive
Bezzdna [24]

Answer:

n= input("Please enter the next word: ")

x=1

while(n != "STOP"):

 print("#" + str(x) + ": You entered " + n)

  x=x+1

  n= input("Please enter the next word: ")

print("All done. " + str(x-1) + " words entered.")

Explanation:

8 0
3 years ago
Elaboren un texto acerca de una caracteristica o<br>componente de algun sistema tecnologico.<br>​
LUCKY_DIMON [66]

Answer:

<em>Teniendo en cuenta el sistema hidráulico se puede mencionar la siguiente característica teniendo en cuenta el principio de Pascal:</em>

  • <u><em>La presión ejercida sobre un fluido en área pequeña es igual a las fuerza ejercida sobre un fluido en un área más grande.</em></u>

Explanation:

<em>El principio de Pascal menciona en términos generales que l</em><u><em>a fuerza ejercida sobre un fluido se ejerce sobre el total del fluido y en todas las direcciones</em></u><em>, sin embargo, basado en este concepto se encuentra el principio de la prensa hidráulica (que se menciona en la respuesta), el cual se podría expresar de la siguiente forma:</em>

  • <em>F1/A1 = F2/A2</em>

<em>Donde:</em>

  • <em>F </em><em>= Fuerza ejercida.</em>
  • <em>A</em><em> = Área en la cual se ejerce la fuerza.</em>

<em>Lo que se busca es ejercer una fuerza en un área pequeña que se vea reflejado como una gran fuerza en un área más grande. Éste principio se suele usar para el levantamiento de maquinaria como automóviles en los concesionarios.</em>

8 0
3 years ago
A report that ends with the author providing his or her plan for next steps is considered a
Angelina_Jolie [31]
The specific part of the report wherein the author would provide his suggestions on the next plans that would be carried out in the study would be the recommendations. In addition, it would open the opportunity to other aspiring researchers to expound and better improve the study.
4 0
3 years ago
Other questions:
  • Tony Stark wants to build a 1000 meter high tower as quickly as possible. He has unlimited resources and an unlimited budget and
    8·2 answers
  • The OSI is a reference system that is used by most types of technicians EXCEPT _____.
    11·2 answers
  • Describe practices that enable software designers to think about using patterns?
    10·1 answer
  • Given the code below, which three statements can be used to create the controller variable?
    5·1 answer
  • What is a phonograph?
    15·2 answers
  • A college has 2.3 ratio of men to women in its student body you what is the ratio of women to men
    15·1 answer
  • Filtering data in Excel Online keeps all data on the screen and highlights the content that fits your criteria.
    9·1 answer
  • Write convert() method to cast double to int
    7·1 answer
  • 2. The<br>is the main and usually largest data storage hardware device in a computer​
    9·1 answer
  • What can you achieve if you divide your search engine marketing account into relevant campaigns and ad groups?.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!