diff --git a/slides/Makefile b/slides/Makefile index b3411621983decb133ccb5a3c87353d872768405..7fcd2e0216e9addf19459038bbab781aee616029 100644 --- a/slides/Makefile +++ b/slides/Makefile @@ -25,7 +25,8 @@ docker_clean: docker-compose.yml puppeteer: @echo "Setting chromium to $(CHROMIUM) for puppeteer" - @echo -e "{\n\"executablePath\":" \"$(CHROMIUM)\" ",\n\"args\": [\"--no-sandbox\"]\n}" > .puppeteer.json + # @echo -e "{\n\"executablePath\":" \"$(CHROMIUM)\" ",\n\"args\": [\"--no-sandbox\"]\n}" > .puppeteer.json + @echo "{\n\"executablePath\":" \"$(CHROMIUM)\" ",\n\"args\": [\"--no-sandbox\"]\n}" > .puppeteer.json index.md: gen_index.sh $(shell ./gen_index.sh) diff --git a/slides/cours_16.md b/slides/cours_16.md index a4a443372ca057caaa45f5229bf0d5bed5b6579b..222010e1bc7de67b58e5a391136870b9623145ad 100644 --- a/slides/cours_16.md +++ b/slides/cours_16.md @@ -1,6 +1,6 @@ --- title: "Arbres binaires" -date: "2024-03-07" +date: "2025-03-07" --- # Les arbres binaires diff --git a/source_codes/complexity/.gitignore b/source_codes/complexity/.gitignore index a391e6cd4cbee9e31cbccb810592e40aab2b98c0..40bafa0c9b83480beb167aeae58820cd8bb20720 100644 --- a/source_codes/complexity/.gitignore +++ b/source_codes/complexity/.gitignore @@ -4,3 +4,17 @@ sum_one sum_one_opt sum_thousand sum_thousand_opt +search +sum +sum_one +sum_one_opt +sum_thousand +sum_thousand_opt +sum_one +sum_one_opt +sum_thousand +sum_thousand_opt +sum_one +sum_one_opt +sum_thousand +sum_thousand_opt diff --git a/source_codes/complexity/sum.c b/source_codes/complexity/sum.c index 44e93033acb1430ec923d8a5b90871252b4475e6..fbf04dab72e5fcb35d8be0a3a85d1129cff96745 100644 --- a/source_codes/complexity/sum.c +++ b/source_codes/complexity/sum.c @@ -11,34 +11,35 @@ #endif void init(int n, double tab[]) { - for (int i = 0; i < n; ++i) { - tab[i] = (double)rand() / (double)RAND_MAX; - } + for (int i = 0; i < n; ++i) { + tab[i] = (double)rand() / (double)RAND_MAX; + } } double sum(int n, double tab[]) { - double s = tab[0]; - for (int i = 1; i < n; ++i) { - s += tab[i] * tab[i] * tab[i] * tab[i]; - } - return s; + double s = tab[0]; + for (int i = 1; i < n; ++i) { + s += tab[i] * tab[i] * tab[i] * tab[i]; + } + return s; } int main() { - double tab[SIZE]; - init(SIZE, tab); + double tab[SIZE]; + init(SIZE, tab); - struct timespec tstart = {0, 0}, tend = {0, 0}; - clock_gettime(CLOCK_MONOTONIC, &tstart); - double s = 0; - for (int i = 0; i < NUM_TIMES; ++i) { - s += sum(SIZE, tab); - } - clock_gettime(CLOCK_MONOTONIC, &tend); - printf("the computation took about %.5f seconds\n", - (((double)tend.tv_sec + 1e-9 * tend.tv_nsec) - - ((double)tstart.tv_sec + 1e-9 * tstart.tv_nsec)) / - NUM_TIMES); + struct timespec tstart = {0, 0}, tend = {0, 0}; + clock_gettime(CLOCK_MONOTONIC, &tstart); + double s = 0; + for (int i = 0; i < NUM_TIMES; ++i) { + s += sum(SIZE, tab); + } + clock_gettime(CLOCK_MONOTONIC, &tend); + printf("the computation took about %.15f seconds\n", + (((double)tend.tv_sec + 1e-9 * tend.tv_nsec) - + ((double)tstart.tv_sec + 1e-9 * tstart.tv_nsec)) / + NUM_TIMES); + printf("%lf\n", s); - return 0; + return 0; }