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]
3 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]3 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
Readable code includes the use of
Kobotan [32]

Answer:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBbBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBbbbbbbbbbbbbbbbbbbbbbbbbBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB

Explanation:

7 0
2 years ago
Read 2 more answers
Why can't cruise control work under 25 mph?
beks73 [17]
<span>At lower speeds modulating speeds is a must for safety. I would be hard pressed to find a place in town you could drive 25 mph for an extended time. Also, plan on a lot of shifting at lower speeds. That completely negates using the cruise on a manual and really puts the auto in the hunting mode. I would think it safer that you move the selector into a lower gear to get some engine braking at say, 25 mph which would make it easier to sustain the speed rather then use the cruise.

Brainliest please?</span>
4 0
3 years ago
Is there actually a difference between left and right twix
olga2289 [7]
One has more caramel and one has more cookie
6 0
2 years ago
How to get the pc accelerate pro virus off my computer
garik1379 [7]
Try to see a computer specialist to help
4 0
2 years ago
Read 2 more answers
Let A be a 2D list in Python containing randomly assigned values where its size is also randomly generated up to 10 rows and 10
lana [24]

Answer:

Rows and cols of matrix1 : 5 6

Rows and cols of matrix1 : 4 4

We can't multiply these two as matrices.

Rows and cols of matrix1 : 3 8

Rows and cols of matrix1 : 8 6

We can multiply these two as matrices.

Explanation:

Note: Check attachment for the code. Also note that "page (1/3), page (2/3) and page (3/3)" are not part of the code, it is only for numbering the  pages.

So, the aim in this question is to check if we can multiply the two lists given above as matrices. So, check below for what we are are going to input as the Python3 program which is in the attached file.

Therefore, when we write the Python3 program  and run it we are going to get an output which will read as the following;

Rows and cols of matrix1 : 5 6

Rows and cols of matrix1 : 4 4

We can't multiply these two as matrices.

Rows and cols of matrix1 : 3 8

Rows and cols of matrix1 : 8 6

6 0
3 years ago
Other questions:
  • What is a nonlinear presentation
    9·2 answers
  • Suppose your parents are planning to take you
    8·1 answer
  • Without protocols the information sent and received through the Internet would never reach its intended target and even if it di
    6·1 answer
  • Given the class 'ReadOnly' with the following behavior: A (protected) integer instance variable named 'val'. A constructor that
    8·1 answer
  • Which of the following is not the name of a java wrapper class from the Java API?
    14·1 answer
  • Suppose for the worst case, given input size n: Algorithm 1 performs f(n) = n2 + n/2 steps Algorithm 2 performs f(n) = 12n + 500
    6·1 answer
  • HURRY!!!!!!!!!!!!!
    15·1 answer
  • , 13 dB correspond to a power ratio of ....?
    14·1 answer
  • Which one of these is NOT a type of printer
    10·2 answers
  • Why does Brainly not have a astronomy section. (I'd prefer brainly answer this)
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!