Homework 7, Part A: Big-O

Learning Goals

Task: Find the running time of statements in a method

Consider the following method that removes a CD from a linear collection (e.g. array).

code to remove a CD from an array

Assume that the collection has n CDs to start with. Answer each of the questions below. Provide your answer by writing a sentence for each question, and then explaining the Big-O notation associated with the relevant statement.

Note: If you find any of the Questions ambiguous (that is, it may mean two different things and you are not sure which one is the correct interpretation), explain why and give your answer for each alternative.

Write your answer in a text file called BigO.txt (not a Word .doc or some other special format—just plain text) and submit it in the proper assignment folder.


Homework 7, Part B: Trace Sorting by hand

Learning Goals

Exercise: Trace Sorting Algorithms

Complete the following questions on paper by hand, scan them as a PDF, and submit as the file SortingTrace.pdf to Gradescope.

Given the following array of numbers:

255 31 15 127 511 1023 63 7 2047

Show a trace of execution for each of the sorting methods as shown in the book:

  1. selection sort (listing 13.5, page 492)
  2. insertion sort (listing 13.5, page 493)
  3. merge sort (listing 13.5, page 495)

The meaning of “trace” depends on each sorting method.

What to submit


Submission Checklist