From 49c4599639c9015ea879cc9d8ccf819e09df271d Mon Sep 17 00:00:00 2001 From: Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> Date: Sun, 18 Feb 2024 00:02:53 +0000 Subject: Sat, Feb 17, 2024, 4:02 PM -08:00 --- wk3/lab/bubble.c | 20 -------------------- wk3/lab/iteration.c | 21 --------------------- wk3/lab/notes.txt | 12 ------------ wk3/lab/selection.c | 35 ----------------------------------- wk3/lect/bubble.c | 20 ++++++++++++++++++++ wk3/lect/iteration.c | 21 +++++++++++++++++++++ wk3/lect/notes.txt | 12 ++++++++++++ wk3/lect/selection.c | 35 +++++++++++++++++++++++++++++++++++ 8 files changed, 88 insertions(+), 88 deletions(-) delete mode 100644 wk3/lab/bubble.c delete mode 100644 wk3/lab/iteration.c delete mode 100644 wk3/lab/notes.txt delete mode 100644 wk3/lab/selection.c create mode 100644 wk3/lect/bubble.c create mode 100644 wk3/lect/iteration.c create mode 100644 wk3/lect/notes.txt create mode 100644 wk3/lect/selection.c (limited to 'wk3') diff --git a/wk3/lab/bubble.c b/wk3/lab/bubble.c deleted file mode 100644 index 3d95665..0000000 --- a/wk3/lab/bubble.c +++ /dev/null @@ -1,20 +0,0 @@ -#include <cs50.h> -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -int main(void) { - -} - - -/* - look at each pair of numbers i & i +1 - if they're out of order swap them - repeat until completely sorted - - worst sorting method - O(n^2) - Q(n) -*/ diff --git a/wk3/lab/iteration.c b/wk3/lab/iteration.c deleted file mode 100644 index 32a8a9d..0000000 --- a/wk3/lab/iteration.c +++ /dev/null @@ -1,21 +0,0 @@ -#include <cs50.h> -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -void draw(int n); - -int main(void) { - int height = get_int("Height: "); - draw(height); -} - -void draw(int n) { - for (int i = 0; i < n; i++) { - for (int j = 0; j < i + 1; j++) { - printf("#"); - } - printf("\n"); - } -} diff --git a/wk3/lab/notes.txt b/wk3/lab/notes.txt deleted file mode 100644 index 9336a56..0000000 --- a/wk3/lab/notes.txt +++ /dev/null @@ -1,12 +0,0 @@ - -Order - O(n^2): Selection, Bubble - O(n): - O(logn): - O(c): - -Omega - Q(n^2): Selection - Q(n): Bubble - Q(logn): - Q(c): diff --git a/wk3/lab/selection.c b/wk3/lab/selection.c deleted file mode 100644 index c6887b5..0000000 --- a/wk3/lab/selection.c +++ /dev/null @@ -1,35 +0,0 @@ -#include <cs50.h> -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -int main(void) { - int arr[] = - int n = arr.length - for (int i = 0; i < n - 1; i++) { - int n; - int m; - for (int j = i; j < n - 1; j++) { - if (arr[j] < n || n === undefined) { - n = arr[j]; - m = j; - } - } - int k = arr[i]; - arr[i] = n; - arr[m] = k; - } -} - - -/* - grab the first value and record it - go throught each value and record the smallest - swap the 1st value and the smallest value - repeat - - O(n^2) - Q(n^2) Omega - 0(n^2) -*/ diff --git a/wk3/lect/bubble.c b/wk3/lect/bubble.c new file mode 100644 index 0000000..3d95665 --- /dev/null +++ b/wk3/lect/bubble.c @@ -0,0 +1,20 @@ +#include <cs50.h> +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int main(void) { + +} + + +/* + look at each pair of numbers i & i +1 + if they're out of order swap them + repeat until completely sorted + + worst sorting method + O(n^2) + Q(n) +*/ diff --git a/wk3/lect/iteration.c b/wk3/lect/iteration.c new file mode 100644 index 0000000..32a8a9d --- /dev/null +++ b/wk3/lect/iteration.c @@ -0,0 +1,21 @@ +#include <cs50.h> +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +void draw(int n); + +int main(void) { + int height = get_int("Height: "); + draw(height); +} + +void draw(int n) { + for (int i = 0; i < n; i++) { + for (int j = 0; j < i + 1; j++) { + printf("#"); + } + printf("\n"); + } +} diff --git a/wk3/lect/notes.txt b/wk3/lect/notes.txt new file mode 100644 index 0000000..9336a56 --- /dev/null +++ b/wk3/lect/notes.txt @@ -0,0 +1,12 @@ + +Order + O(n^2): Selection, Bubble + O(n): + O(logn): + O(c): + +Omega + Q(n^2): Selection + Q(n): Bubble + Q(logn): + Q(c): diff --git a/wk3/lect/selection.c b/wk3/lect/selection.c new file mode 100644 index 0000000..c6887b5 --- /dev/null +++ b/wk3/lect/selection.c @@ -0,0 +1,35 @@ +#include <cs50.h> +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int main(void) { + int arr[] = + int n = arr.length + for (int i = 0; i < n - 1; i++) { + int n; + int m; + for (int j = i; j < n - 1; j++) { + if (arr[j] < n || n === undefined) { + n = arr[j]; + m = j; + } + } + int k = arr[i]; + arr[i] = n; + arr[m] = k; + } +} + + +/* + grab the first value and record it + go throught each value and record the smallest + swap the 1st value and the smallest value + repeat + + O(n^2) + Q(n^2) Omega + 0(n^2) +*/ -- cgit v1.2.3