summaryrefslogtreecommitdiff
path: root/wk3/lab/selection.c
diff options
context:
space:
mode:
authorFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-02-17 23:34:58 +0000
committerFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-02-17 23:34:58 +0000
commit337b5915e7092d6479004ae4771297aa4555cb14 (patch)
treef753cfc375cd72b5435fc77fa8bf8f8c6bb06a5f /wk3/lab/selection.c
parent8c2a6725d4dd95398da287d54bde6b4ef08f8688 (diff)
Sat, Feb 17, 2024, 3:34 PM -08:00
Diffstat (limited to 'wk3/lab/selection.c')
-rw-r--r--wk3/lab/selection.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/wk3/lab/selection.c b/wk3/lab/selection.c
index 93e1cc7..d740b59 100644
--- a/wk3/lab/selection.c
+++ b/wk3/lab/selection.c
@@ -5,11 +5,12 @@
#include <string.h>
int main(void) {
- int arr[] =
- for (int i = 0; i < arr.length - 1; i++) {
+ int arr[] =
+ int n = arr.length
+ for (int i = 0; i < n - 1; i++) {
int n;
int m;
- for (int j = i; j < arr.length - 1; j++) {
+ for (int j = i; j < n - 1; j++) {
if (arr[j] < n || n === undefined) {
n = arr[j];
m = j;
@@ -28,5 +29,5 @@ int main(void) {
swap the 1st value and the smallest value
repeat
-
+ O(n)
*/