Lab: Sorting

Analyze three sorting programs to determine which algorithms they use.

Background

In class, we saw a few algorithms for sorting a sequence of numbers: selection sort, bubble sort, and merge sort.

Getting Started

  1. Open your CS50 Codespace.
  2. In the terminal window, run wget https://scienceacademy.github.io/web/lab3.zip to download a zip file of the lab code.
  3. In the terminal window, run unzip lab3.zip to unzip (decompress) the file.
  4. In the terminal window, run cd lab3 to change directories into your lab3 directory.

Instructions

You’ve been provided with three already-compiled C programs, sort1, sort2, and sort3. Each of these programs implements a different sorting algorithm: selection sort, bubble sort, or merge sort (though not necessarily in that order!). Your task is to determine which sorting algorithm is used by each program.

Hints

The different types of .txt files may help you determine which sort is which. Consider how each algorithm performs with an already sorted list. How about a reversed list? Or shuffled list? It may help to work through a smaller list of each type and walk through each sorting process.

How to Check Your Answers

Execute the below to evaluate the correctness of your answers using check50. But be sure to fill in your explanations as well, which check50 won’t check here!

check50 scienceacademy/problems/2024ap/sort

How to Submit

submit50 scienceacademy/problems/2024ap/sort