• Verkeerd document? Gratis ruilen
  • Geschreven door studenten die geslaagd zijn
  • Direct beschikbaar na je betaling
  • Online lezen of als PDF
Verkopen
Kies je studieland
Kies je taal
Document preview thumbnail
Voorbeeld 1 van de 2 pagina's
College aantekeningen

CSC108 Worksheet Sorting

Document preview thumbnail
Voorbeeld 1 van de 2 pagina's

Computer Science CSC108 Worksheet Sorting

Voorbeeld van de inhoud

CSC108H Fall 2022 Worksheet: Insertion Sort Analysis


1. Insertion Sort: Worst Case
(a) In the list below, 4 passes of the insertion sort algorithm have been completed, and the double bar
separates the sorted part of the list from the unsorted part. The item at index i is missing. Fill in
the missing item with a value that will cause insert(L, i) to perform the most number of steps.
(As a reminder, this is called the worst case.)
i

L 3 4 6 6 3 1 5

(b) When insert(L, i) is executed on the example list, how many times does the while loop iterate?




(c) When insert(L, i) is called on the example list, how many assignment statements are executed?




(d) In general, in the worst case, on pass i of insertion sort, how many times does the while loop iterate?
(Your answer should be a formula that involves i.)




(e) In general, in the worst case, on pass i of insertion sort, how many assignment statements are
executed? (Again, your answer should be a formula that involves i.)




(f) In terms of i, in the worst case, does function insert have constant running time, linear running
time, quadratic running time, or some other running time?

(a) constant (b) linear (c) quadratic (d) something else

(g) In function insertion_sort, the first time that function insert is called, i is 0; the second time, i
is 1; and so on. What value does i have the last time that function insert is called?




(h) For the call insertion_sort(L), in the worst case, write a formula expressing how many compar-
isons are made during all the calls to insert.




(i) In the worst case, does insertion_sort have constant running time, linear running time, quadratic
running time, or some other running time?

(a) constant (b) linear (c) quadratic (d) something else

Documentinformatie

Studie
Geüpload op
14 december 2022
Aantal pagina's
2
Geschreven in
2022/2023
Type
College aantekeningen
Docent(en)
N/a
Bevat
12
$8.49

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Verkocht
2
Volgers
1
Items
25
Laatst verkocht
3 jaar geleden



Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen