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
rue or false: The first web browser was introduced to the public in the 1970s and started the explosive growth of the Internet i
saw5 [17]

Answer:

false.

Explanation:

it was introduced in 1994

8 0
2 years ago
Which of the following will increase the level of security for personal and confidential information on a mobile device if the d
Soloha48 [4]
I believe is a and c.
8 0
3 years ago
. When you create a template class, ___________.
shepuryov [24]

Answer:

 All of the above options are incorrect, as the template class is the type of class in which it generate the various types of classes and also provide the specifications according to the specific parameters. The class template is basically initialized by passing all the given types to its argument in the given template function.

 The template class are basically created by using the special types of functions which can be operated with the help of generic types without repeating the whole code in the given class.

Therefore, All the options are incorrect.  

5 0
3 years ago
Why is it a good idea to view your HTML code in more than one web browser
Mandarinka [93]

Because some features may not be available on some browsers. By viewing it on different browsers, we can see if there's any incompatibilities and fix them.

5 0
3 years ago
Draw the hierarchy chart and then plan the logic for a program that calculates a person’s body mass index (BMI).
dusya [7]

Explanation:

I have attached the answer as an image. I can't upload the file as it requires a licensed product and I only used demo version. I can provide the file too if you can give me your vlsig file required to use full software. However, If you just copy along the images on your Visual Studio, you will easily create the files yourself. Answer is provided for both scenarios as part A and part B, one which stops after 1 iteration and the one which loops until 0 height is given.

8 0
3 years ago
Other questions:
  • Because log-on procedures may be cumbersome and tedious, users often store log-on sequences in their personal computers and invo
    6·1 answer
  • 10 points (sorry it won’t let me do more points)
    10·1 answer
  • Write a program that uses these bounds and bisection search (for more info check out the Wikipedia page on bisection search) to
    8·1 answer
  • Why does my hp computer keep freezing when i move it?
    10·1 answer
  • What malware looks like a useful or desired executable program but is, in reality, a program that is supposed to cause harm to y
    11·1 answer
  • How do you award a brainliest
    8·2 answers
  • 1. A bank customer invested $24 in a bank with 5 percent simple interest per year, write a program the construct a table showing
    11·1 answer
  • Can someone send me reference on communication, importance , communication cycle , pros and cos​
    15·1 answer
  • Whats the flow in this code, and whats the risk that its creating and what can i do to fix it? (c language)
    10·1 answer
  • PLSS HELP ASAP ILL GIVE BRAINLIES THANKS
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!