diff options
Diffstat (limited to 'content/digarden/pages/20210513013257-алгоритмы.org')
-rw-r--r-- | content/digarden/pages/20210513013257-алгоритмы.org | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/content/digarden/pages/20210513013257-алгоритмы.org b/content/digarden/pages/20210513013257-алгоритмы.org new file mode 100644 index 0000000..9555708 --- /dev/null +++ b/content/digarden/pages/20210513013257-алгоритмы.org @@ -0,0 +1,34 @@ +:PROPERTIES: +:ID: 190cef43-efe6-4049-9efd-a96bd515878e +:END: +#+title: Алгоритмы +https://algs4.cs.princeton.edu/home/ + +[[https://www.bigocheatsheet.com/][Сложность структур данных и алгоритмов: инфографика]] + +[[https://qph.cf2.quoracdn.net/main-qimg-c2702ecbf207c08ad8aab565d5d831a4-lq][Список алгоритмов картинкой]] + +* Quicksort +Создатель быстрой сортировки [[https://ru.wikipedia.org/wiki/%D0%A5%D0%BE%D0%B0%D1%80,_%D0%A7%D0%B0%D1%80%D0%BB%D1%8C%D0%B7_%D0%AD%D0%BD%D1%82%D0%BE%D0%BD%D0%B8_%D0%A0%D0%B8%D1%87%D0%B0%D1%80%D0%B4][Чарлз Хоар]] + +** Python +#+begin_src python + global_arr = [3, 1, 2, 5, 4, 7, 9, 8, 10] + + def qsort(arr): + if len(arr) == 0: + return arr + + middle = arr.pop() + + lArr = list(filter(lambda x: x <= middle, arr)) + rArr = list(filter(lambda x: x > middle, arr)) + + print("qsort({}) + [{}] + qsort({}); Array: {} Middle: {}" + .format(lArr, middle, rArr, arr, middle )) + + return qsort(lArr) + [middle] + qsort(rArr) + + print(global_arr) + qsort(global_arr) +#+end_src |