Skip to content
Snippets Groups Projects
Commit 8194b057 authored by Romain Vuillemot's avatar Romain Vuillemot
Browse files

exercices + updates syllabus

parent 01a64b53
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id:2bb7e285 tags:
# UE5 Fundamentals of Algorithms
## Exercices
### Ecole Centrale de Lyon, Bachelor of Science in Data Science for Responsible Business
#### [Romain Vuillemot](https://romain.vuillemot.net/)
Before you turn this problem in:
- make sure everything runs as expected.
- first, **restart the kernel** (in the menubar, select Kernel$\rightarrow$Restart)
- then **run all cells** (in the menubar, select Cell$\rightarrow$Run All).
- make sure you fill in any place that says `YOUR CODE HERE` or "YOUR ANSWER HERE"
- remove `raise NotImplementedError()` to get started with your answer
- bonus points (at the end of this notebook) are optionals
- write your name (and collaborators as a list if any) below:
%% Cell type:code id:20dd5861 tags:
``` python
ID = ""
COLLABORATORS_ID = []
```
%% Cell type:markdown id:f00472a3 tags:
---
%% Cell type:markdown id:a4e4fad3 tags:
# Data Structures and Complexity
%% Cell type:markdown id:a8adef9b tags:
---
%% Cell type:code id:761a1dba-a197-4206-92a2-78920211f9f1 tags:
``` python
list_complexities = ["O(1)", "O(log(n))", "O(n)", "O(n^2)", "O(nlog(n))",
"O(n^3)", "O(2^n)", "O(n!)", "O(n^n)"]
```
%% Cell type:markdown id:568202fd tags:
### Exercise 1: Identify the complexity
%% Cell type:code id:431fe8c1-91d1-40f3-a7a4-f4a3770a4a01 tags:
``` python
def nested_loop_example(arr):
n = len(arr)
for i in range(n):
for j in range(n):
print(arr[i] + arr[j])
```
%% Cell type:code id:e68b3e9a-418f-4950-9f27-18bb0fe90794 tags:
``` python
# nested_loop_example_complexity = ?
# YOUR CODE HERE
raise NotImplementedError()
```
%% Cell type:markdown id:612dc873-419b-42c5-be36-0accd03ffa79 tags:
### Exercise 2: Identify the complexity
%% Cell type:code id:76102853-e1f3-4717-8a59-1091195a19eb tags:
``` python
def fibonacci_recursive(n):
if n <= 1:
return n
return fibonacci_recursive(n - 1) + fibonacci_recursive(n - 2)
```
%% Cell type:code id:dead6a52-7996-4eae-9d2a-f75d5d26bbb7 tags:
``` python
# fibonacci_recursive_complexity = ?
# YOUR CODE HERE
raise NotImplementedError()
```
%% Cell type:markdown id:aa4a6ce7-e542-4b23-8a10-ca0bf93de041 tags:
### Exercise 3: Identify the complexity
%% Cell type:code id:70af3e43-8053-49c9-ba58-346a3e915bdb tags:
``` python
def binary_search(arr, target):
low, high = 0, len(arr) - 1
while low <= high:
mid = (low + high) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
low = mid + 1
else:
high = mid - 1
return -1
```
%% Cell type:code id:9c22866c-b4fc-4228-b0ab-5882d964f5f6 tags:
``` python
# binary_searche_complexity = ?
# YOUR CODE HERE
raise NotImplementedError()
```
...@@ -27,6 +27,14 @@ Instructor: [Romain Vuillemot](romain.vuillemot@ec-lyon.fr) ...@@ -27,6 +27,14 @@ Instructor: [Romain Vuillemot](romain.vuillemot@ec-lyon.fr)
📖 [Python for Everybody](pdf/pythonlearn.pdf) chapter 8 (lists) 📖 [Python for Everybody](pdf/pythonlearn.pdf) chapter 8 (lists)
### Assignment 1 - TBD
### Lecture 4 - **Divide and conquer and greedy algorithms**
### Lecture 5 - **Dynamic programming**
### Assignment 2 - TBD
Next topics: Next topics:
1. **Advanced sorting** 1. **Advanced sorting**
...@@ -37,19 +45,15 @@ Next topics: ...@@ -37,19 +45,15 @@ Next topics:
4. **Trees and their representation** 4. **Trees and their representation**
5. **Tree Algorithms** 5. **Tree algorithms**
6. **Binary and n-trees** 6. **Binary and n-trees**
7. **Graphs** 8. **Graphs**
8. **Divide and conquer Programming**
9. **Dynamic Programming**
10. **Greedy Algorithms** 9. **Graphs algorithms**
11. **Graphs shortest path algorithm** 10. **Graphs shortest path algorithm**
## Books ## Books
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment