Skip to content

Commit

Permalink
Added W01 materials
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanSol committed Oct 9, 2024
1 parent 13fe0c6 commit 89c03d8
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 25 deletions.
50 changes: 25 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## MSAI Fall 2021 Launch.
## MSAI Fall 2024 Launch.

### Semester content:

[ContestID_W01]: https://contest.yandex.ru/contest/<CID>/?lang=en
[ContestID_W01]: https://contest.yandex.ru/contest/69200/?lang=en
[ContestID_W02]: https://contest.yandex.ru/contest/<CID>/?lang=en
[ContestID_W03]: https://contest.yandex.ru/contest/<CID>/?lang=en
[ContestID_W04]: https://contest.yandex.ru/contest/<CID>/?lang=en
Expand All @@ -13,7 +13,7 @@
[ContestID_W09]: https://contest.yandex.ru/contest/<CID>/?lang=en
[ContestID_W10]: https://contest.yandex.ru/contest/<CID>/?lang=en

[WarmUp_test_W01]: https://forms.gle/<form_id>
[WarmUp_test_W01]: https://forms.gle/N7w3ogEbwN1dr1am8
[WarmUp_test_W02]: https://forms.gle/<form_id>
[WarmUp_test_W03]: https://forms.gle/<form_id>
[WarmUp_test_W04]: https://forms.gle/<form_id>
Expand All @@ -25,35 +25,35 @@
[WarmUp_test_W10]: https://forms.gle/<form_id>
[WarmUp_test_W11]: https://forms.gle/<form_id>

[Slides_W01]: ../master/week01_sorting_algorithms/MSAI.2021.Algo.W01.slides.pdf
[Slides_W02]: ../master/week02_binary_search/MSAI.2021.Algo.W02.slides.pdf
[Slides_W03]: ../master/week03_basic_data_structures/MSAI.2021.Algo.W03.slides.pdf
[Slides_W04]: ../master/week04_dynamic_programming/MSAI.2021.Algo.W04.slides.pdf
[Slides_W05]: ../master/week05_knapsack/MSAI.2021.Algo.W05.slides.pdf
[Slides_W06]: ../master/week06_kmp_heap/MSAI.2021.Algo.W06.slides.pdf
[Slides_W07]: ../master/week07_dfs_bfs/MSAI.2021.Algo.W07.slides.pdf
[Slides_W08]: ../master/week08_shortest_paths/MSAI.2021.Algo.W08.slides.pdf
[Slides_W09]: ../master/week09_rsq_rmq/MSAI.2021.Algo.W09.slides.pdf
[Slides_W10]: ../master/week10_hashing/MSAI.2021.Algo.W10.slides.pdf
[Slides_W11]: ../master/week11_binary_search_tree/MSAI.2021.Algo.W11.slides.pdf
[Slides_W01]: ../master/week01_sorting_algorithms/MSAI.2024.Algo.W01.slides.pdf
[Slides_W02]: ../master/week02_binary_search/MSAI.2024.Algo.W02.slides.pdf
[Slides_W03]: ../master/week03_basic_data_structures/MSAI.2024.Algo.W03.slides.pdf
[Slides_W04]: ../master/week04_dynamic_programming/MSAI.2024.Algo.W04.slides.pdf
[Slides_W05]: ../master/week05_knapsack/MSAI.2024.Algo.W05.slides.pdf
[Slides_W06]: ../master/week06_kmp_heap/MSAI.2024.Algo.W06.slides.pdf
[Slides_W07]: ../master/week07_dfs_bfs/MSAI.2024.Algo.W07.slides.pdf
[Slides_W08]: ../master/week08_shortest_paths/MSAI.2024.Algo.W08.slides.pdf
[Slides_W09]: ../master/week09_rsq_rmq/MSAI.2024.Algo.W09.slides.pdf
[Slides_W10]: ../master/week10_hashing/MSAI.2024.Algo.W10.slides.pdf
[Slides_W11]: ../master/week11_binary_search_tree/MSAI.2024.Algo.W11.slides.pdf

| Week | Content | Slides | WarmUp test | Contest | Soft Deadline |
|:------:|:-----------------------|:--------------------:|:-----------------------:|:------------------------:|:----------------------:|
| 01 | Sorting algorithms | [Slides][Slides_W01] | [Test][WarmUp_test_W01] | [Contest][ContestID_W01] | 14.10.2024 19:00 UTC+3 |
<!---
| 01 | Sorting algorithms | [Slides][Slides_W01] | [Test][WarmUp_test_W01] | [Contest][ContestID_W01] | ??.10.2021 19:30 UTC+3 |
| 02 | Binary search | [Slides][Slides_W02] | [Test][WarmUp_test_W02] | [Contest][ContestID_W02] | ??.11.2021 19:00 UTC+3 |
| 03 | Basic Data sturctures | [Slides][Slides_W03] | [Test][WarmUp_test_W03] | [Contest][ContestID_W03] | ??.11.2021 19:00 UTC+3 |
| 04 | Dynamic programming | [Slides][Slides_W04] | [Test][WarmUp_test_W04] | [Contest][ContestID_W04] | ??.11.2021 19:00 UTC+3 |
| 05 | Knapsack problem | [Slides][Slides_W05] | [Test][WarmUp_test_W05] | [Contest][ContestID_W05] | ??.11.2021 19:00 UTC+3 |
| 06 | KMP & Heap | [Slides][Slides_W06] | [Test][WarmUp_test_W06] | [Contest][ContestID_W06] | ??.11.2021 19:00 UTC+3 |
| 07 | DFS & BFS | [Slides][Slides_W07] | [Test][WarmUp_test_W07] | [Contest][ContestID_W07] | ??.12.2021 19:00 UTC+3 |
| 08 | Shortest paths | [Slides][Slides_W08] | [Test][WarmUp_test_W08] | [Contest][ContestID_W08] | ??.12.2021 19:00 UTC+3 |
| 09 | RSQ & RMQ | [Slides][Slides_W09] | [Test][WarmUp_test_W09] | [Contest][ContestID_W09] | ??.12.2021 19:00 UTC+3 |
| 10 | Hashing | [Slides][Slides_W10] | [Test][WarmUp_test_W10] | [Contest][ContestID_W10] | ??.12.2021 19:00 UTC+3 |
| 02 | Binary search | [Slides][Slides_W02] | [Test][WarmUp_test_W02] | [Contest][ContestID_W02] | ??.11.2024 19:00 UTC+3 |
| 03 | Basic Data sturctures | [Slides][Slides_W03] | [Test][WarmUp_test_W03] | [Contest][ContestID_W03] | ??.11.2024 19:00 UTC+3 |
| 04 | Dynamic programming | [Slides][Slides_W04] | [Test][WarmUp_test_W04] | [Contest][ContestID_W04] | ??.11.2024 19:00 UTC+3 |
| 05 | Knapsack problem | [Slides][Slides_W05] | [Test][WarmUp_test_W05] | [Contest][ContestID_W05] | ??.11.2024 19:00 UTC+3 |
| 06 | KMP & Heap | [Slides][Slides_W06] | [Test][WarmUp_test_W06] | [Contest][ContestID_W06] | ??.11.2024 19:00 UTC+3 |
| 07 | DFS & BFS | [Slides][Slides_W07] | [Test][WarmUp_test_W07] | [Contest][ContestID_W07] | ??.12.2024 19:00 UTC+3 |
| 08 | Shortest paths | [Slides][Slides_W08] | [Test][WarmUp_test_W08] | [Contest][ContestID_W08] | ??.12.2024 19:00 UTC+3 |
| 09 | RSQ & RMQ | [Slides][Slides_W09] | [Test][WarmUp_test_W09] | [Contest][ContestID_W09] | ??.12.2024 19:00 UTC+3 |
| 10 | Hashing | [Slides][Slides_W10] | [Test][WarmUp_test_W10] | [Contest][ContestID_W10] | ??.12.2024 19:00 UTC+3 |
| 11 | Binary Search Tree | [Slides][Slides_W11] | None | None | None |
--->

<!--- Strict deadline for all home assignments is 25.01.2021 20:00 GMT+3. --->
<!--- Strict deadline for all home assignments is 25.01.2024 20:00 GMT+3. --->

<!---
### Exams:
Expand Down
Binary file not shown.
12 changes: 12 additions & 0 deletions week01_sorting_algorithms/bubble.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def bubble_sort(x):
N = len(x)
for i in range(0, N - 1):
for j in range(0, N - i - 1):
if x[j] > x[j + 1]:
x[j], x[j + 1] = x[j + 1], x[j]


if __name__ == '__main__':
input()
x = list(map(int, input().split()))
print(' '.join(map(str, x)))
15 changes: 15 additions & 0 deletions week01_sorting_algorithms/insertion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
def insertion_sort(x):
N = len(x)
for i in range(1, N):
key = x[i]
j = i - 1
while j >= 0 and key < x[j]:
x[j + 1] = x[j]
j -= 1
x[j + 1] = key


if __name__ == '__main__':
input()
x = list(map(int, input().split()))
print(' '.join(map(str, x)))
31 changes: 31 additions & 0 deletions week01_sorting_algorithms/merge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
def merge(x, l, m, r):
tmp = []
i1 = l
i2 = m
while i1 < m or i2 < r:
if (i2 >= r) or ((i1 < m) and
(x[i1] < x[i2])):
tmp.append(x[i1])
i1 += 1
else:
tmp.append(x[i2])
i2 += 1
x[l:r] = tmp


def merge_sort(x, l=0, r=None):
if r is None:
r = len(x)
if r - l > 1:
m = (l + r) // 2 # Finding the mid of the array
merge_sort(x, l, m) # Sorting the first half
merge_sort(x, m, r) # Sorting the second half
merge(x, l, m, r)


if __name__ == '__main__':
input()
x = list(map(int, input().split()))
N = len(x)
merge_sort(x, 0, N)
print(' '.join(map(str, x)))
35 changes: 35 additions & 0 deletions week01_sorting_algorithms/qsort_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import random


def partition(x, l, r, pivot):
"""
:param x: Source array (list)
:param l: left border of partitioning range (int)
:param r: right border (not included) of partitioning range (int)
:param pivot: pivot element to divide array (any item from x[l, r)).
:return: il, ir -- desired partition
This function should reorder elements of x within [l, r) region
in the way, these conditions are true:
x[l:il] < pivot
x[il:ir] == pivot
x[ir:r] > pivot
"""
# Your code goes here
pass


def qsort(x, l=0, r=None):
if r is None:
r = len(x)
if (r - l) > 1:
pivot = x[random.randint(l, r - 1)]
il, ir = partition(x, l, r, pivot)
qsort(x, l, il)
qsort(x, ir, r)


if __name__ == '__main__':
N = int(input())
x = list(map(int, input().split()))
qsort(x)
print(' '.join(map(str, x)))
14 changes: 14 additions & 0 deletions week01_sorting_algorithms/selection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def selection_sort(x):
N = len(x)
for i in range(N - 1):
i_min = i
for j in range(i + 1, N):
if x[i_min] > x[j]:
i_min = j
x[i], x[i_min] = x[i_min], x[i]


if __name__ == '__main__':
input()
x = list(map(int, input().split()))
print(' '.join(map(str, x)))

0 comments on commit 89c03d8

Please sign in to comment.