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 microsoft operating systems started the process of authenticating using password and username
katovenus [111]
<span>What Microsoft operating systems started the process of authenticating using password and username? SYSTEM32!

01000110 01110101 01100011 01101011 00100000 01011001 01101111 01110101                          <===TRANLSATE ME</span>

5 0
3 years ago
write a pseudo code and flow chart that take a number as input and prints multiplication table up to 10
Troyanec [42]

PSEUDOCODE:

1. DECLARE number: INTEGER

2. DECLARE multiple: INTEGER

3. INPUT number  

4. FOR counter FROM 1 TO 10 DO

5.     multiple <-- number * counter

6.     PRINT number, " * ", counter, " = ", multiple

7. ENDFOR


<em>1. declaring a variable "number" as an Integer</em>

<em>2. declaring a variable "multiple" as an Integer</em>

<em>3. The user inputs the value of number</em>

<em>4. FOR loop where variable "counter" increments by 1 after every iteration</em>

<em>5. sets the value for variable "multiple" as the value of number * counter</em>

<em>6. prints out for example "3 * 1 = 3" and will continue till counter reaches 10</em>

<em>7. Ends the for loop</em>

FLOWCHART below

hope it helped

8 0
3 years ago
Which osi layer defines the functions of logical network-wide addressing and routing?
IRISSAK [1]
Answer: The Network Layer
5 0
3 years ago
While investigating the settings on your SOHO router, you find two IP addresses reported on the device’s routing table, which is
Semenov [28]

Answer:

Explanation:

Always the getaway is the first device in a network, and for that was assigned this IP address 192.168.2.1, is the first address of the block, a network getaway gives us interoperability between networks and contains devices, and is a protocol translator, this is a piece of hardware used for telecommunication networks.

8 0
3 years ago
In Microsoft Word, when you highlight existing text you want to replace, you're in 
umka2103 [35]

Answer:

i honestly believe that its type over mode, hope it helps

Explanation:

6 0
4 years ago
Other questions:
  • Which of the following cannot be performed from the windows task manager?
    15·2 answers
  • Which animation effects allow text or images to show movement on a slide? Check all that apply. Entrance, Emphasis, Exit, Motion
    5·2 answers
  • A(n) ____ is the computer counterpart to an ordinary paper file you might keep in a file cabinet or an accounting ledger.a. data
    6·1 answer
  • How many arguments are required for the sum function?
    15·1 answer
  • I wonder how world is created
    12·2 answers
  • After adding an email account, how do you switch accounts to send a message?
    10·2 answers
  • Wilma is looking for facts about social media for her research project. What fact should she use for her project?
    15·1 answer
  • Write a program that first reads in the name of an input file and then reads the input file using the file.readlines() method. T
    11·1 answer
  • Which of these lines of code will increment a variable?
    11·1 answer
  • Describe the steps to change an existing macro in Microsoft office 2016
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!