Week 11
Week of 11/6
Unit 2
In Class | Homework | |
---|---|---|
Mon | Merge Sort | Lab for this unit |
Tue | Cover how to swap values in class, then do Bubble Sort Practice below | |
Wed | Start on Practice Problems: 1. Average Temperatures (make sure you have done swap and Bubble Sort practice first) 2. Max |
|
Thu | Go over Max and start practice FRQs on this program I’ll put the questions in Teams so anyone that is going to be out won’t miss anything |
|
Fri | Finish FRQ |
Bubble Sort Practice
- Write a program
bubble.c
that sorts an array of integers using bubble sort. - Distribution Code:
#include <cs50.h>
#include <stdio.h>
int main(void)
{
// Get input
int n = get_int("How many values? ");
int values[n];
for (int i = 0; i < n; i++)
{
values[i] = get_int("Value %i: ", i);
}
// TODO: sort numbers
// Print sorted values
for (int i = 0; i < n; i++)
{
printf("%i\n", values[i]);
}
}