100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
CSC108 Worksheet Sorting CA$11.82
Add to cart

Class notes

CSC108 Worksheet Sorting

 6 views  0 purchase

Computer Science CSC108 Worksheet Sorting

Preview 1 out of 2  pages

  • December 14, 2022
  • 2
  • 2022/2023
  • Class notes
  • N/a
  • 12
All documents for this subject (4)
avatar-seller
yudasu
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

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller yudasu. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for CA$11.82. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

53022 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
CA$11.82
  • (0)
Add to cart
Added