From e5b5944c6849389bbfc39f476fa7a1f97d8ce4c6 Mon Sep 17 00:00:00 2001 From: Alexander Cyon Date: Sat, 13 Jul 2024 20:56:39 +0200 Subject: [PATCH 01/11] Fix four typos (#1139) --- .../uncategorized/best-time-to-buy-sell-stocks/README.md | 2 +- src/algorithms/uncategorized/n-queens/README.md | 2 +- src/data-structures/bloom-filter/README.md | 2 +- src/data-structures/heap/Heap.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/algorithms/uncategorized/best-time-to-buy-sell-stocks/README.md b/src/algorithms/uncategorized/best-time-to-buy-sell-stocks/README.md index 9446993e..975eade3 100644 --- a/src/algorithms/uncategorized/best-time-to-buy-sell-stocks/README.md +++ b/src/algorithms/uncategorized/best-time-to-buy-sell-stocks/README.md @@ -46,7 +46,7 @@ Let's say we have an array of prices `[7, 6, 4, 3, 1]` and we're on the _1st_ da 1. _Option 1: Keep the money_ → profit would equal to the profit from buying/selling the rest of the stocks → `keepProfit = profit([6, 4, 3, 1])`. 2. _Option 2: Buy/sell at current price_ → profit in this case would equal to the profit from buying/selling the rest of the stocks plus (or minus, depending on whether we're selling or buying) the current stock price → `buySellProfit = -7 + profit([6, 4, 3, 1])`. -The overall profit would be equal to → `overalProfit = Max(keepProfit, buySellProfit)`. +The overall profit would be equal to → `overallProfit = Max(keepProfit, buySellProfit)`. As you can see the `profit([6, 4, 3, 1])` task is being solved in the same recursive manner. diff --git a/src/algorithms/uncategorized/n-queens/README.md b/src/algorithms/uncategorized/n-queens/README.md index 077e26d7..39925676 100644 --- a/src/algorithms/uncategorized/n-queens/README.md +++ b/src/algorithms/uncategorized/n-queens/README.md @@ -59,7 +59,7 @@ and return false. queen here leads to a solution. b) If placing queen in [row, column] leads to a solution then return true. - c) If placing queen doesn't lead to a solution then umark this [row, + c) If placing queen doesn't lead to a solution then unmark this [row, column] (Backtrack) and go to step (a) to try other rows. 3) If all rows have been tried and nothing worked, return false to trigger backtracking. diff --git a/src/data-structures/bloom-filter/README.md b/src/data-structures/bloom-filter/README.md index e156310c..7880a7f7 100644 --- a/src/data-structures/bloom-filter/README.md +++ b/src/data-structures/bloom-filter/README.md @@ -93,7 +93,7 @@ three factors: the size of the bloom filter, the number of hash functions we use, and the number of items that have been inserted into the filter. -The formula to calculate probablity of a false positive is: +The formula to calculate probability of a false positive is: ( 1 - e -kn/m ) k diff --git a/src/data-structures/heap/Heap.js b/src/data-structures/heap/Heap.js index 45dfcfa2..b978739e 100644 --- a/src/data-structures/heap/Heap.js +++ b/src/data-structures/heap/Heap.js @@ -279,7 +279,7 @@ export default class Heap { /* istanbul ignore next */ pairIsInCorrectOrder(firstElement, secondElement) { throw new Error(` - You have to implement heap pair comparision method + You have to implement heap pair comparison method for ${firstElement} and ${secondElement} values. `); } From 9046d80bdb9e5c2e65c87369575a3e47e9c01978 Mon Sep 17 00:00:00 2001 From: Mahdi Azarboon <21277296+azarboon@users.noreply.github.com> Date: Sun, 14 Jul 2024 02:58:45 +0800 Subject: [PATCH 02/11] Update README.md (#1141) Before diving into any of the data structures, readers should be reminded of two fundamental laws in software architecture: 1.Everything is a trade-ff 2."Why is more important than the how" So, readers face the nuances and reality of these data structures from the beginning. These two laws are coined by two thought leaders in software architecture: Mark Richards and Neal Ford. They have explained these two laws in various conference talks and books. For example, here you can read about these two laws here: https://www.infoq.com/podcasts/software-architecture-hard-parts/ Also, here is a book for reference: https://a.co/d/fKOodW9 Co-authored-by: Oleksii Trekhleb <3000285+trekhleb@users.noreply.github.com> --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e06cfb90..8fa63142 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,8 @@ be accessed and modified efficiently. More precisely, a data structure is a coll values, the relationships among them, and the functions or operations that can be applied to the data. +Remember that each data has its own trade-offs. And you need to pay attention more to why you're choosing a certain data structure than to how to implement it. + `B` - Beginner, `A` - Advanced * `B` [Linked List](src/data-structures/linked-list) From d7a41a64610db25caa4525d61e9f8545fcb491c5 Mon Sep 17 00:00:00 2001 From: Qudratillo <80141037+softXengineer@users.noreply.github.com> Date: Sun, 14 Jul 2024 00:09:06 +0500 Subject: [PATCH 03/11] feat: added uzbek language (#1082) Co-authored-by: Oleksii Trekhleb <3000285+trekhleb@users.noreply.github.com> --- README.ar-AR.md | 3 +- README.de-DE.md | 3 +- README.es-ES.md | 3 +- README.fr-FR.md | 3 +- README.id-ID.md | 3 +- README.it-IT.md | 3 +- README.ja-JP.md | 3 +- README.ko-KR.md | 3 +- README.md | 3 +- README.pl-PL.md | 3 +- README.pt-BR.md | 3 +- README.ru-RU.md | 3 +- README.tr-TR.md | 3 +- README.uk-UA.md | 3 +- README.uz-UZ.md | 358 ++++++++++++++++++++++++++++++++++++++++++++++++ README.zh-CN.md | 3 +- README.zh-TW.md | 3 +- 17 files changed, 390 insertions(+), 16 deletions(-) create mode 100644 README.uz-UZ.md diff --git a/README.ar-AR.md b/README.ar-AR.md index cbcfd024..fedd29c0 100644 --- a/README.ar-AR.md +++ b/README.ar-AR.md @@ -23,7 +23,8 @@ _اقرأ هذا في لغات أخرى:_ [_Türk_](README.tr-TR.md), [_Italiana_](README.it-IT.md), [_Tiếng Việt_](README.vi-VN.md), -[_Deutsch_](README.de-DE.md) +[_Deutsch_](README.de-DE.md), +[_Uzbek_](README.uz-UZ.md) ☝ ملاحضة هذا المشروع مخصص للاستخدام لأغراض التعلم والبحث فقط ، و ** ليست ** معدة للاستخدام في **الإنتاج** diff --git a/README.de-DE.md b/README.de-DE.md index b34ad356..9663f7b0 100644 --- a/README.de-DE.md +++ b/README.de-DE.md @@ -24,7 +24,8 @@ _Lies dies in anderen Sprachen:_ [_Italiana_](README.it-IT.md), [_Bahasa Indonesia_](README.id-ID.md), [_Українська_](README.uk-UA.md), -[_Arabic_](README.ar-AR.md) +[_Arabic_](README.ar-AR.md), +[_Uzbek_](README.uz-UZ.md) _☝ Beachte, dass dieses Projekt nur für Lern- und Forschungszwecke gedacht ist und **nicht** für den produktiven Einsatz verwendet werden soll_ diff --git a/README.es-ES.md b/README.es-ES.md index d79baf60..24d1990a 100644 --- a/README.es-ES.md +++ b/README.es-ES.md @@ -25,7 +25,8 @@ _Léelo en otros idiomas:_ [_Українська_](README.uk-UA.md), [_Arabic_](README.ar-AR.md), [_Tiếng Việt_](README.vi-VN.md), -[_Deutsch_](README.de-DE.md) +[_Deutsch_](README.de-DE.md), +[_Uzbek_](README.uz-UZ.md) *☝ Nótese que este proyecto está pensado con fines de aprendizaje e investigación, y **no** para ser usado en producción.* diff --git a/README.fr-FR.md b/README.fr-FR.md index 469a4f52..be8258be 100644 --- a/README.fr-FR.md +++ b/README.fr-FR.md @@ -26,7 +26,8 @@ _Lisez ceci dans d'autres langues:_ [_Українська_](README.uk-UA.md), [_Arabic_](README.ar-AR.md), [_Tiếng Việt_](README.vi-VN.md), -[_Deutsch_](README.de-DE.md) +[_Deutsch_](README.de-DE.md), +[_Uzbek_](README.uz-UZ.md) ## Data Structures diff --git a/README.id-ID.md b/README.id-ID.md index b204f2a8..2f4310fe 100644 --- a/README.id-ID.md +++ b/README.id-ID.md @@ -23,7 +23,8 @@ _Baca ini dalam bahasa yang lain:_ [_Українська_](README.uk-UA.md), [_Arabic_](README.ar-AR.md), [_Tiếng Việt_](README.vi-VN.md), -[_Deutsch_](README.de-DE.md) +[_Deutsch_](README.de-DE.md), +[_Uzbek_](README.uz-UZ.md) _☝ Perhatikan bahwa proyek ini hanya dimaksudkan untuk tujuan pembelajaran dan riset, dan **tidak** dimaksudkan untuk digunakan sebagai produksi._ diff --git a/README.it-IT.md b/README.it-IT.md index 6ac47fa5..a86c52cf 100644 --- a/README.it-IT.md +++ b/README.it-IT.md @@ -22,7 +22,8 @@ _Leggilo in altre lingue:_ [_Українська_](README.uk-UA.md), [_Arabic_](README.ar-AR.md), [_Tiếng Việt_](README.vi-VN.md), -[_Deutsch_](README.de-DE.md) +[_Deutsch_](README.de-DE.md), +[_Uzbek_](README.uz-UZ.md) *☝ Si noti che questo progetto è destinato ad essere utilizzato solo per l'apprendimento e la ricerca e non è destinato ad essere utilizzato per il commercio.* diff --git a/README.ja-JP.md b/README.ja-JP.md index e10bb940..6e3a8b81 100644 --- a/README.ja-JP.md +++ b/README.ja-JP.md @@ -25,7 +25,8 @@ _Read this in other languages:_ [_Українська_](README.uk-UA.md), [_Arabic_](README.ar-AR.md), [_Tiếng Việt_](README.vi-VN.md), -[_Deutsch_](README.de-DE.md) +[_Deutsch_](README.de-DE.md), +[_Uzbek_](README.uz-UZ.md) ## データ構造 diff --git a/README.ko-KR.md b/README.ko-KR.md index b48c43aa..9aac387e 100644 --- a/README.ko-KR.md +++ b/README.ko-KR.md @@ -24,7 +24,8 @@ _Read this in other languages:_ [_Українська_](README.uk-UA.md), [_Arabic_](README.ar-AR.md), [_Tiếng Việt_](README.vi-VN.md), -[_Deutsch_](README.de-DE.md) +[_Deutsch_](README.de-DE.md), +[_Uzbek_](README.uz-UZ.md) ## 자료 구조 diff --git a/README.md b/README.md index 8fa63142..a2067398 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,8 @@ _Read this in other languages:_ [_Українська_](README.uk-UA.md), [_Arabic_](README.ar-AR.md), [_Tiếng Việt_](README.vi-VN.md), -[_Deutsch_](README.de-DE.md) +[_Deutsch_](README.de-DE.md), +[_Uzbek_](README.uz-UZ.md) *☝ Note that this project is meant to be used for learning and researching purposes only, and it is **not** meant to be used for production.* diff --git a/README.pl-PL.md b/README.pl-PL.md index 52ba75a5..9fac028a 100644 --- a/README.pl-PL.md +++ b/README.pl-PL.md @@ -26,7 +26,8 @@ _Read this in other languages:_ [_Українська_](README.uk-UA.md), [_Arabic_](README.ar-AR.md), [_Tiếng Việt_](README.vi-VN.md), -[_Deutsch_](README.de-DE.md) +[_Deutsch_](README.de-DE.md), +[_Uzbek_](README.uz-UZ.md) ## Struktury Danych diff --git a/README.pt-BR.md b/README.pt-BR.md index a937e8c0..edb2bd44 100644 --- a/README.pt-BR.md +++ b/README.pt-BR.md @@ -26,7 +26,8 @@ _Leia isto em outros idiomas:_ [_Українська_](README.uk-UA.md), [_Arabic_](README.ar-AR.md), [_Tiếng Việt_](README.vi-VN.md), -[_Deutsch_](README.de-DE.md) +[_Deutsch_](README.de-DE.md), +[_Uzbek_](README.uz-UZ.md) ## Estrutura de Dados diff --git a/README.ru-RU.md b/README.ru-RU.md index 541e1d27..b926b5ea 100644 --- a/README.ru-RU.md +++ b/README.ru-RU.md @@ -23,7 +23,8 @@ _Читать на других языках:_ [_Українська_](README.uk-UA.md), [_Arabic_](README.ar-AR.md), [_Tiếng Việt_](README.vi-VN.md), -[_Deutsch_](README.de-DE.md) +[_Deutsch_](README.de-DE.md), +[_Uzbek_](README.uz-UZ.md) *☝ Замечание: этот репозиторий предназначен для учебно-исследовательских целей (**не** для использования в продакшн-системах).* diff --git a/README.tr-TR.md b/README.tr-TR.md index 805bf7b4..fada4e0b 100644 --- a/README.tr-TR.md +++ b/README.tr-TR.md @@ -23,7 +23,8 @@ _Read this in other languages:_ [_Українська_](README.uk-UA.md), [_Arabic_](README.ar-AR.md), [_Tiếng Việt_](README.vi-VN.md), -[_Deutsch_](README.de-DE.md) +[_Deutsch_](README.de-DE.md), +[_Uzbek_](README.uz-UZ.md) *☝ Not, bu proje araştırma ve öğrenme amacı ile yapılmış olup üretim için **yapılmamıştır**.* diff --git a/README.uk-UA.md b/README.uk-UA.md index dd129b2c..e79a8ae8 100644 --- a/README.uk-UA.md +++ b/README.uk-UA.md @@ -23,7 +23,8 @@ _Вивчення матеріалу на інших мовах:_ [_Bahasa Indonesia_](README.id-ID.md), [_Arabic_](README.ar-AR.md), [_Tiếng Việt_](README.vi-VN.md), -[_Deutsch_](README.de-DE.md) +[_Deutsch_](README.de-DE.md), +[_Uzbek_](README.uz-UZ.md) *☝ Зверніть увагу! Даний проект призначений лише для навчальних та дослідницьких цілей, і він **не** призначений для виробництва (продакшн).* diff --git a/README.uz-UZ.md b/README.uz-UZ.md new file mode 100644 index 00000000..130c1f99 --- /dev/null +++ b/README.uz-UZ.md @@ -0,0 +1,358 @@ +# JavaScript algoritmlari va ma'lumotlar tuzilmalari + +[![CI](https://github.com/trekhleb/javascript-algorithms/workflows/CI/badge.svg)](https://github.com/trekhleb/javascript-algorithms/actions?query=workflow%3ACI+branch%3Amaster) +[![codecov](https://codecov.io/gh/trekhleb/javascript-algorithms/branch/master/graph/badge.svg)](https://codecov.io/gh/trekhleb/javascript-algorithms) +![repo size](https://img.shields.io/github/repo-size/trekhleb/javascript-algorithms.svg) + +Bu repozitoriyada JavaScript-ga asoslangan ko'plab mashhur algoritmlar +va ma'lumotlar tuzilmalarining namunalari mavjud. + +Har bir algoritm va ma'lumotlar tuzilmasining alohida README fayli +bo'lib, unda tegishli tushuntirishlar va qo'shimcha o'qish uchun +havolalar (shu jumladan YouTube videolariga ham havolalar) mavjud. + +_Read this in other languages:_ +[_简体中文_](README.zh-CN.md), +[_繁體中文_](README.zh-TW.md), +[_한국어_](README.ko-KR.md), +[_日本語_](README.ja-JP.md), +[_Polski_](README.pl-PL.md), +[_Français_](README.fr-FR.md), +[_Español_](README.es-ES.md), +[_Português_](README.pt-BR.md), +[_Русский_](README.ru-RU.md), +[_Türkçe_](README.tr-TR.md), +[_Italiana_](README.it-IT.md), +[_Bahasa Indonesia_](README.id-ID.md), +[_Українська_](README.uk-UA.md), +[_Arabic_](README.ar-AR.md), +[_Tiếng Việt_](README.vi-VN.md), +[_Deutsch_](README.de-DE.md), +[_Uzbek_](README.uz-UZ.md) + +Yodda tuting, bu loyiha faqat o'quv va tadqiqot maqsadida ishlatilishi +uchun mo'ljallangan va ishlab chiqarishda ishlatilishi **mumkin emas**. + +## Ma'lumotlar tuzilmalari + +Ma'lumotlar tuzilmasi - bu kompyuterda ma'lumotlarni samarali tarzda +olish va o'zgartirish uchun ularni tashkil etish va saqlashning ma'lum +bir usuli. Ayniqsa, ma'lumotlar tuzilmasi ma'lumot qiymatlarining +to'plami, ular orasidagi munosabatlar va ma'lumotlarga qo'llanilishi +mumkin bo'lgan funksiyalar yoki operatsiyalardir. + +`B` - Boshlang'ich, `A` - Ilg'or + +- `B` [Bog'langan ro'yxat](src/data-structures/linked-list) +- `B` [Ikki marta bog'langan ro'yxat](src/data-structures/doubly-linked-list) +- `B` [Navbat](src/data-structures/queue) +- `B` [Stek](src/data-structures/stack) +- `B` [Hash jadvali](src/data-structures/hash-table) +- `B` [Heap](src/data-structures/heap) - maksimal va minimal heap versiyalari +- `B` [Ustuvor navbat](src/data-structures/priority-queue) +- `A` [Trie](src/data-structures/trie) +- `A` [Daraxt](src/data-structures/tree) + - `A` [Ikkilik qidiruv daraxt](src/data-structures/tree/binary-search-tree) + - `A` [AVL daraxt](src/data-structures/tree/avl-tree) + - `A` [Qizil-qora daraxt](src/data-structures/tree/red-black-tree) + - `A` [Segment daraxt](src/data-structures/tree/segment-tree) - min/max/sum diapazon so'rovlari bilan misollar + - `A` [Fenwick daraxt](src/data-structures/tree/fenwick-tree) (ikkilik indeksli daraxt) +- `A` [Graf](src/data-structures/graph) (yo'naltirilgan hamda yo'naltirilmagan) +- `A` [Ajratilgan to'plam](src/data-structures/disjoint-set) - union-find ma'lumotlar strukturasi yoki merge-find to'plami +- `A` [Bloom filtri](src/data-structures/bloom-filter) +- `A` [LRU keshi](src/data-structures/lru-cache/) - Eng kam ishlatilgan (LRU) keshi + +## Algoritmlar + +Algoritm muammolar sinfini qanday hal qilishning aniq spetsifikatsiyasi. Bu operatsiyalar ketma-ketligini aniqlaydigan qoidalar to'plami. + +`B` - Boshlang'ich, `A` - Ilg'or + +### Mavzu bo'yicha algoritmlar + +- **Matematika** + - `B` [Bit manipulatsiyasi](src/algorithms/math/bits) - bitlarni qo'yish/olish/yangilash/tozalash, ikkilikka ko'paytirish/bo'lish, manfiy qilish va hokazo. + - `B` [Ikkilik suzuvchi nuqta](src/algorithms/math/binary-floating-point) - suzuvchi nuqtali sonlarning ikkilik tasviri. + - `B` [Faktorial](src/algorithms/math/factorial) + - `B` [Fibonachchi raqam](src/algorithms/math/fibonacci) - klassik va yopiq shakldagi versiyalar + - `B` [Asosiy omillar](src/algorithms/math/prime-factors) - tub omillarni topish va ularni Xardi-Ramanujan teoremasi yordamida sanash + - `B` [Birlamchilik testi](src/algorithms/math/primality-test) (sinov bo'linish usuli) + - `B` [Evklid algoritmi](src/algorithms/math/euclidean-algorithm) - eng katta umumiy bo'luvchini (EKUB) hisoblash + - `B` [Eng kichik umumiy karrali](src/algorithms/math/least-common-multiple) (EKUK) + - `B` [Eratosfen elagi](src/algorithms/math/sieve-of-eratosthenes) - berilgan chegaragacha barcha tub sonlarni topish + - `B` [Ikkining darajasimi](src/algorithms/math/is-power-of-two) - raqamning ikkining darajasi ekanligini tekshirish (sodda va bitli algoritmlar) + - `B` [Paskal uchburchagi](src/algorithms/math/pascal-triangle) + - `B` [Kompleks sonlar](src/algorithms/math/complex-number) - kompleks sonlar va ular bilan asosiy amallar + - `B` [Radian & Daraja](src/algorithms/math/radian) - radianlarni darajaga va orqaga aylantirish + - `B` [Tez ko'tarish](src/algorithms/math/fast-powering) + - `B` [Horner metodi](src/algorithms/math/horner-method) - polinomlarni baholash + - `B` [Matritsalar](src/algorithms/math/matrix) - matritsalar va asosiy matritsa operatsiyalari (ko'paytirish, transpozitsiya va boshqalar). + - `B` [Evklid masofasi](src/algorithms/math/euclidean-distance) - ikki nuqta/vektor/matritsa orasidagi masofa + - `A` [Butun sonlarni bo'lish](src/algorithms/math/integer-partition) + - `A` [Kvadrat ildiz](src/algorithms/math/square-root) - Nyuton metodi + - `A` [Liu Hui π algoritmi](src/algorithms/math/liu-hui) - N-gonlarga asoslangan π ning taxminiy hisoblari + - `A` [Diskret Furye transformatsiyasi](src/algorithms/math/fourier-transform) - vaqt funksiyasini (signalni) uni tashkil etuvchi chastotalarga ajratish +- **Sets** + - `B` [Karteziya maxsuloti](src/algorithms/sets/cartesian-product) - bir nechta to'plamlarning ko'paytmasi + - `B` [Fisher–Yates Shuffle](src/algorithms/sets/fisher-yates) - chekli ketma-ketlikni tasodifiy almashtirish + - `A` [Power Set](src/algorithms/sets/power-set) - to'plamning barcha kichik to'plamlari (bitwise, backtracking va kaskadli echimlar) + - `A` [Permutatsiyalar](src/algorithms/sets/permutations) (takroriyalash bilan va takroriyalashsiz) + - `A` [Kombinatsiyalar](src/algorithms/sets/combinations) (takroriyalash bilan va takroriyalashsiz) + - `A` [Eng uzun umumiy ketma-ketlik](src/algorithms/sets/longest-common-subsequence) (LCS) + - `A` [Eng uzun ortib boruvchi ketma-ketlik](src/algorithms/sets/longest-increasing-subsequence) + - `A` [Eng qisqa umumiy ketma-ketlik](src/algorithms/sets/shortest-common-supersequence) (SCS) + - `A` [Knapsack muammosi](src/algorithms/sets/knapsack-problem) - "0/1" va "Bir-biriga bog'lanmagan" + - `A` [Maksimal kichik massiv](src/algorithms/sets/maximum-subarray) - Toʻliq kuch va dinamik dasturlash (Kadane usuli) versiyalari + - `A` [Kombinatsiya yig'indisi](src/algorithms/sets/combination-sum) - ma'lum summani tashkil etuvchi barcha kombinatsiyalarni topish +- **Stringlar** + - `B` [Hamming masofasi](src/algorithms/string/hamming-distance) - belgilarning bir-biridan farq qiladigan pozitsiyalar soni + - `B` [Palindrom](src/algorithms/string/palindrome) - satrning teskari tomoni ham bir xil ekanligini tekshirish + - `A` [Levenshtein masofasi](src/algorithms/string/levenshtein-distance) - ikki ketma-ketlik o'rtasidagi minimal tahrirlash masofasi + - `A` [Knuth–Morris–Pratt Algoritmi](src/algorithms/string/knuth-morris-pratt) (KMP Algoritmi) - kichik qatorlarni qidirish (mosh keluvchi naqshni qidirish) + - `A` [Z Algoritmi](src/algorithms/string/z-algorithm) - kichik qatorlarni qidirish (mosh keluvchi naqshni qidirish) + - `A` [Rabin Karp Algoritmi](src/algorithms/string/rabin-karp) - kichik qatorlarni qidirish + - `A` [Eng uzun umumiy kichik matn](src/algorithms/string/longest-common-substring) + - `A` [Regulyar ifoda moslashuvi](src/algorithms/string/regular-expression-matching) (RegEx) +- **Qidiruvlar** + - `B` [Linear qidirish](src/algorithms/search/linear-search) + - `B` [Jump qidirish](src/algorithms/search/jump-search) (yoki Blok qidirish) - saralangan qatorda qidirish + - `B` [Ikkilik qidirish](src/algorithms/search/binary-search) - saralangan qatorda qidirish + - `B` [Interpolatsiya qidirish](src/algorithms/search/interpolation-search) - bir tekis taqsimlangan saralangan qatorda qidirish +- **Tartiblash** + - `B` [Pufakcha tartiblash](src/algorithms/sorting/bubble-sort) + - `B` [Tanlash tartibi](src/algorithms/sorting/selection-sort) + - `B` [Kiritish tartibi](src/algorithms/sorting/insertion-sort) + - `B` [Heap tartibi](src/algorithms/sorting/heap-sort) + - `B` [Birlashtirish tartibi](src/algorithms/sorting/merge-sort) + - `B` [Tezkor saralash](src/algorithms/sorting/quick-sort) - joyida va joyida bo'lmagan amalga oshirish + - `B` [Shell tartiblash](src/algorithms/sorting/shell-sort) + - `B` [Sanash tartibi](src/algorithms/sorting/counting-sort) + - `B` [Radiksli tartiblash](src/algorithms/sorting/radix-sort) + - `B` [Bucket tartiblash](src/algorithms/sorting/bucket-sort) +- **Bog'langan ro'yhatlar** + - `B` [To'g'ri traversal](src/algorithms/linked-list/traversal) + - `B` [Teskari traversal](src/algorithms/linked-list/reverse-traversal) +- **Daraxtlar** + - `B` [Birinchi-pastga qarab qidirish](src/algorithms/tree/depth-first-search) (Depth-First Search) + - `B` [Birinchi-yonga qarab qidirish](src/algorithms/tree/breadth-first-search) (Breadth-First Search) +- **Grafiklar** + - `B` [Birinchi-pastga qarab qidirish](src/algorithms/graph/depth-first-search) (Depth-First Search) + - `B` [Birinchi-yonga qarab qidirish](src/algorithms/graph/breadth-first-search) (Breadth-First Search) + - `B` [Kruskal Algoritmi](src/algorithms/graph/kruskal) - og'irlikdagi yo'naltirilmagan grafik uchun Minimal kengayuvchi daraxtni (MST) topish + - `A` [Dijkstra Algoritmi](src/algorithms/graph/dijkstra) - grafikning bir cho'qqisidan qolgan barcha nuqtalarga eng qisqa yo'llarni topish + - `A` [Bellman-Ford Algoritmi](src/algorithms/graph/bellman-ford) - grafikning bir cho'qqisidan qolgan barcha nuqtalarga eng qisqa yo'llarni topish + - `A` [Floyd-Warshall Algoritmi](src/algorithms/graph/floyd-warshall) - grafikning barcha uchlari orasidagi eng qisqa masofalarni topish + - `A` [Siklni aniqlash](src/algorithms/graph/detect-cycle) - yo'naltirilgan va yo'naltirilmagan grafiklar uchun (DFS va Disjoint Set-ga asoslangan versiyalar) + - `A` [Prim Algoritmi](src/algorithms/graph/prim) - og'irlikdagi yo'naltirilmagan grafik uchun Minimal kengayuvchi daraxtni (MST) topish + - `A` [Topologik saralash](src/algorithms/graph/topological-sorting) - DFS metodi + - `A` [Artikulyatsiya nuqtalari](src/algorithms/graph/articulation-points) - Tarjan algoritmi (DFS asosida) + - `A` [Ko'priklar](src/algorithms/graph/bridges) - DFS asosidagi algoritm + - `A` [Eyler yo'li va Eyler sxemasi](src/algorithms/graph/eulerian-path) - Fleury algoritmi - Har bir chekkaga bir marta tashrif buyurish + - `A` [Gamilton sikli](src/algorithms/graph/hamiltonian-cycle) - Har bir cho'qqiga bir marta tashrif buyurish + - `A` [Kuchli bog'langan komponentlar](src/algorithms/graph/strongly-connected-components) - Kosaraju algoritmi + - `A` [Sayohatchi sotuvchi muammosi](src/algorithms/graph/travelling-salesman) - har bir shaharga tashrif buyuradigan va kelib chiqqan shaharga qaytib keladigan eng qisqa yo'l +- **Kriptografiya** + - `B` [Polynomial Hash](src/algorithms/cryptography/polynomial-hash) - polinomga asoslangan hash funktsiyasi + - `B` [Rail Fence Cipher](src/algorithms/cryptography/rail-fence-cipher) - xabarlarni kodlash uchun transpozitsiya shifrlash algoritmi + - `B` [Caesar Cipher](src/algorithms/cryptography/caesar-cipher) - oddiy almashtirish shifridir + - `B` [Hill Cipher](src/algorithms/cryptography/hill-cipher) - chiziqli algebraga asoslangan almashtirish shifri +- **Machine Learning** + - `B` [NanoNeuron](https://github.com/trekhleb/nano-neuron) - Mashinalar aslida qanday o'rganishi mumkinligini ko'rsatadigan 7 ta oddiy JS funksiyasi (forward/backward tarqalish) + - `B` [k-NN](src/algorithms/ml/knn) - eng yaqin qo'shnilarni tasniflash algoritmi + - `B` [k-Means](src/algorithms/ml/k-means) - k-Means kalsterlash algoritmi +- **Tasvirga ishlov berish** + - `B` [Seam Carving](src/algorithms/image-processing/seam-carving) - kontentga moslashuvchan rasm o'lchamini o'zgartirish algoritmi +- **Statistikalar** + - `B` [Weighted Random](src/algorithms/statistics/weighted-random) - elementlarning og'irligi asosida ro'yxatdan tasodifiy elementni tanlash +- **Evolyutsion algoritmlar** + - `A` [Genetik algoritm](https://github.com/trekhleb/self-parking-car-evolution) - avtoturargohni o'rgatish uchun genetik algoritm qanday qo'llanilishiga misol. +- **Kategoriyasiz** + - `B` [Xanoy minorasi](src/algorithms/uncategorized/hanoi-tower) + - `B` [Kvadrat matritsaning aylanishi](src/algorithms/uncategorized/square-matrix-rotation) - joyidagi algoritm + - `B` [Sakrash o'yini](src/algorithms/uncategorized/jump-game) - orqaga qaytish, dinamik dasturlash (yuqoridan pastga + pastdan yuqoriga) va ochko'z misollar + - `B` [Noyob yo'llar](src/algorithms/uncategorized/unique-paths) - orqaga qaytish, dinamik dasturlash va Paskal uchburchagiga asoslangan misolla + - `B` [Yomg'ir teraslari](src/algorithms/uncategorized/rain-terraces) - yomg'ir suvini ushlab turish muammosi (dinamik dasturlash va qo'pol kuch versiyalari) + - `B` [Rekursiv zinapoya](src/algorithms/uncategorized/recursive-staircase) - yuqoriga chiqish yo'llari sonini hisoblash (4 ta echim) + - `B` [Aksiyalarni sotib olish va sotish uchun eng yaxshi vaqt](src/algorithms/uncategorized/best-time-to-buy-sell-stocks) - bo'linib-zabt etish va bir marta o'tish misollari + - `A` [N-Queens Muommosi](src/algorithms/uncategorized/n-queens) + - `A` [Ritsar sayohati](src/algorithms/uncategorized/knight-tour) + +### Paradigma bo'yicha algoritmlar + +Algorithmic paradigm - bu algoritmlar sinfini loyihalashtirishga asos bo'lib xizmat qiladigan umumiy usul yoki yondashuv. Bu algoritm tushunchasidan yuqori darajadagi abstraktsiya bo'lib, algoritm kompyuter dasturi tushunchasidan yuqori darajadagi abstraktsiya bo'lgani kabi. + +- **Brute Force** - barcha imkoniyatlarni ko'rib chiqib va eng yaxshi echimni tanlash + - `B` [Chiziqli qidirish](src/algorithms/search/linear-search) + - `B` [Yomg'irli teraslar](src/algorithms/uncategorized/rain-terraces) - yomg'ir suvini to'plash muammosi + - `B` [Rekursiv zinapoya](src/algorithms/uncategorized/recursive-staircase) - cho'qqiga chiqish yo'llari sonini hisoblash + - `A` [Maksimal kichik massiv](src/algorithms/sets/maximum-subarray) + - `A` [Sayohatchi sotuvchi muammosi](src/algorithms/graph/travelling-salesman) - har bir shaharga tashrif buyuradigan va kelib chiqqan shaharga qaytib keladigan eng qisqa yo'l + - `A` [Diskret Furye transformatsiyasi](src/algorithms/math/fourier-transform) - vaqt funksiyasini (signalni) uni tashkil etuvchi chastotalarga ajratish +- **Greedy** - kelajakni o'ylamasdan, hozirgi vaqtda eng yaxshi variantni tanlash + - `B` [Sakrash o'yini](src/algorithms/uncategorized/jump-game) + - `A` [Bog'lanmagan yukxalta muammosi](src/algorithms/sets/knapsack-problem) + - `A` [Dijkstra Algoritmi](src/algorithms/graph/dijkstra) - grafikning bir cho'qqisidan qolgan barcha nuqtalarga eng qisqa yo'llarni topish + - `A` [Prim Algoritmi](src/algorithms/graph/prim) - og'irlikdagi yo'naltirilmagan grafik uchun Minimal kengayuvchi daraxtni (MST) topish + - `A` [Kruskal Algoritmi](src/algorithms/graph/kruskal) - og'irlikdagi yo'naltirilmagan grafik uchun Minimal kengayuvchi daraxtni (MST) topish +- **Divide and Conquer** - muammoni kichikroq qismlarga bo'lib va keyin bu qismlarni hal qilish + + - `B` [Ikkilik qidiruv](src/algorithms/search/binary-search) + - `B` [Xanoy minorasi](src/algorithms/uncategorized/hanoi-tower) + - `B` [Paskal uchburchagi](src/algorithms/math/pascal-triangle) + - `B` [Evklid Algoritmi](src/algorithms/math/euclidean-algorithm) - eng katta umumiy bo'luvchini (EKUB) hisoblash + - `B` [Birlashtirish tartibi](src/algorithms/sorting/merge-sort) + - `B` [Tezkor saralash](src/algorithms/sorting/quick-sort) + - `B` [Birinchi-pastga qarab qidirish daraxti](src/algorithms/tree/depth-first-search) (DFS) + - `B` [Birinchi-pastga qarab qidirish grafigi](src/algorithms/graph/depth-first-search) (DFS) + - `B` [Matritsalar](src/algorithms/math/matrix) - turli shakldagi matritsalarni hosil qilish va kesib o'tish + - `B` [Sakrash o'yini](src/algorithms/uncategorized/jump-game) + - `B` [Tez ko'tarish](src/algorithms/math/fast-powering) + - `B` [Aksiyalarni sotib olish va sotish uchun eng yaxshi vaqt](src/algorithms/uncategorized/best-time-to-buy-sell-stocks) - bo'linib-zabt etish va bir marta o'tish misollari + - `A` [Permutatsiyalar](src/algorithms/sets/permutations) (takroriyalash bilan va takroriyalashsiz) + - `A` [Kombinatsiyalar](src/algorithms/sets/combinations) (takroriyalash bilan va takroriyalashsiz) + - `A` [Maksimal kichik massiv](src/algorithms/sets/maximum-subarray) + +- **Dinamik dasturlash** - ilgari topilgan kichik yechimlar yordamida yechim yaratish + - `B` [Fibonachchi raqam](src/algorithms/math/fibonacci) + - `B` [Sakrash o'yini](src/algorithms/uncategorized/jump-game) + - `B` [Noyob yo'llar](src/algorithms/uncategorized/unique-paths) + - `B` [Yomg'ir teraslari](src/algorithms/uncategorized/rain-terraces) - yomg'ir suvini to'plash muammosi + - `B` [Recursive Staircase](src/algorithms/uncategorized/recursive-staircase) - count the number of ways to reach to the top + - `B` [Seam Carving](src/algorithms/image-processing/seam-carving) - kontentga moslashuvchan rasm o'lchamini o'zgartirish algoritmi + - `A` [Levenshtein masofasi](src/algorithms/string/levenshtein-distance) - ikki ketma-ketlik o'rtasidagi minimal tahrirlash masofasi + - `A` [Eng uzun umumiy ketma-ketlik](src/algorithms/sets/longest-common-subsequence) (LCS) + - `A` [Eng uzun umumiy kichik matn](src/algorithms/string/longest-common-substring) + - `A` [Eng uzun ortib boruvchi ketma-ketlik](src/algorithms/sets/longest-increasing-subsequence) + - `A` [Eng qisqa umumiy ketma-ketlik](src/algorithms/sets/shortest-common-supersequence) + - `A` [0/1 Knapsak muommosi](src/algorithms/sets/knapsack-problem) + - `A` [Butun sonlarni bo'lish](src/algorithms/math/integer-partition) + - `A` [Maksimal kichik massiv](src/algorithms/sets/maximum-subarray) + - `A` [Bellman-Ford Algoritmi](src/algorithms/graph/bellman-ford) - grafikning bir cho'qqisidan qolgan barcha nuqtalarga eng qisqa yo'llarni topish + - `A` [Floyd-Warshall Algoritmi](src/algorithms/graph/floyd-warshall) -grafikning barcha uchlari orasidagi eng qisqa masofalarni topish + - `A` [Regulyar ifoda moslashuvi](src/algorithms/string/regular-expression-matching) +- **Backtracking** - brute forcega o'xshab, barcha mumkin bo'lgan yechimlarni generatsiya qilishga harakat qiladi, lekin har safar keyingi yechimni yaratganingizda, yechim barcha shartlarga javob beradimi yoki yo'qligini tekshirasiz va shundan keyingina keyingi yechimlarni ishlab chiqarishni davom ettirasiz. Aks holda, orqaga qaytib, yechim topishning boshqa yo'liga o'tasiz. Odatda state-space ning DFS-qidiruvi ishlatiladi. + - `B` [Sakrash o'yini](src/algorithms/uncategorized/jump-game) + - `B` [Noyob yo'llar](src/algorithms/uncategorized/unique-paths) + - `B` [Power Set](src/algorithms/sets/power-set) - to'plamning barcha kichik to'plamlari + - `A` [Gamilton sikli](src/algorithms/graph/hamiltonian-cycle) - Har bir cho'qqiga bir marta tashrif buyurish + - `A` [N-Queens muommosi](src/algorithms/uncategorized/n-queens) + - `A` [Ritsar sayohati](src/algorithms/uncategorized/knight-tour) + - `A` [Kombinatsiya yig'indisi](src/algorithms/sets/combination-sum) - ma'lum summani tashkil etuvchi barcha kombinatsiyalarni topish +- **Branch & Bound** - shu paytgacha topilgan eng arzon echimdan kattaroq xarajatlarga ega qisman echimlarni bekor qilish uchun, backtracking qidiruvining har bir bosqichida topilgan eng arzon echimni eslab qoling va shu paytgacha topilgan eng arzon yechim narxidan muammoni eng kam xarajatli yechim narxining past chegarasi sifatida foydalaning. Odatda state-space daraxtining DFS o'tishi bilan birgalikda BFS traversal qo'llaniladi. + +## Ushbu repozitoriyadan qanday foydalanish kerak + +**Barcha dependensiylarni o'rnating** + +``` +npm install +``` + +**ESLint ni ishga tushiring** + +Kod sifatini tekshirish uchun ESLint ni ishga tushirishingiz mumkin. + +``` +npm run lint +``` + +**Barcha testlarni ishga tushuring** + +``` +npm test +``` + +**Testlarni nom bo'yicha ishga tushirish** + +``` +npm test -- 'LinkedList' +``` + +**Muammolarni bartaraf qilish (Troubleshooting)** + +Agar linting yoki sinov muvaffaqiyatsiz bo'lsa, `node_modules` papkasini o'chirib, npm paketlarini qayta o'rnatishga harakat qiling: + +``` +rm -rf ./node_modules +npm i +``` + +Shuningdek, to'g'ri Node versiyasidan foydalanayotganingizga ishonch hosil qiling (`>=16`). Agar Node versiyasini boshqarish uchun [nvm](https://github.com/nvm-sh/nvm) dan foydalanayotgan bo'lsangiz, loyihaning ildiz papkasidan `nvm use` ni ishga tushiring va to'g'ri versiya tanlanadi. + +**O'yin maydoni (Playground)** + +`./src/playground/playground.js` faylida ma'lumotlar strukturalari va algoritmlar bilan o'ynashingiz, `./src/playground/test/playground.test.js` faylida esa ular uchun testlar yozishingiz mumkin. + +Shundan so'ng, playground kodingiz kutilgandek ishlashini tekshirish uchun quyidagi buyruqni ishga tushirishingiz kifoya: + +``` +npm test -- 'playground' +``` + +## Foydali ma'lumotlar + +### Manbalar + +- [▶ Data Structures and Algorithms on YouTube](https://www.youtube.com/playlist?list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8) +- [✍🏻 Data Structure Sketches](https://okso.app/showcase/data-structures) + +### Big O Notation + +_Big O notation_ algoritmlarni kirish hajmi oshgani sayin ularning ishlash vaqti yoki bo'sh joy talablari qanday o'sishiga qarab tasniflash uchun ishlatiladi. Quyidagi jadvalda siz Big O notatsiyasida ko'rsatilgan algoritmlarning o'sishining eng keng tarqalgan tartiblarini topishingiz mumkin. + +![Big O grafiklar](./assets/big-o-graph.png) + +Manba: [Big O Cheat Sheet](http://bigocheatsheet.com/). + +Quyida eng ko'p qo'llaniladigan Big O notatsiyalarining ro'yxati va ularning kirish ma'lumotlarining turli o'lchamlariga nisbatan ishlashini taqqoslash keltirilgan. + +| Big O Notatsiya | Turi | 10 ta element uchun hisob-kitoblar | 100 ta element uchun hisob-kitoblar | 1000 ta element uchun hisob-kitoblar | +| --------------- | ------------ | ---------------------------------- | ----------------------------------- | ------------------------------------ | +| **O(1)** | O'zgarmas | 1 | 1 | 1 | +| **O(log N)** | Logarifmik | 3 | 6 | 9 | +| **O(N)** | Chiziqli | 10 | 100 | 1000 | +| **O(N log N)** | n log(n) | 30 | 600 | 9000 | +| **O(N^2)** | Kvadrat | 100 | 10000 | 1000000 | +| **O(2^N)** | Eksponensial | 1024 | 1.26e+29 | 1.07e+301 | +| **O(N!)** | Faktorial | 3628800 | 9.3e+157 | 4.02e+2567 | + +### Ma'lumotlar tuzilmalarining operatsiyalari murakkabligi + +| Ma'lumotlar tuzilmalari | Kirish | Qidirish | Kiritish | O'chirish | Izohlar | +| --------------------------- | :----: | :------: | :------: | :-------: | :--------------------------------------------------------- | +| **Massiv** | 1 | n | n | n | | +| **Stak** | n | n | 1 | 1 | | +| **Navbat** | n | n | 1 | 1 | | +| **Bog'langan ro'yhat** | n | n | 1 | n | | +| **Hash jadval** | - | n | n | n | Mukammal xash funksiyasi bo'lsa, xarajatlar O (1) bo'ladi. | +| **Ikkilik qidiruv daraxti** | n | n | n | n | Balanslangan daraxt narxida O(log(n)) bo'ladi. | +| **B-daraxti** | log(n) | log(n) | log(n) | log(n) | | +| **Qizil-qora daraxt** | log(n) | log(n) | log(n) | log(n) | | +| **AVL Daraxt** | log(n) | log(n) | log(n) | log(n) | | +| **Bloom filtri** | - | 1 | 1 | - | Qidiruv paytida noto'g'ri pozitivlar bo'lishi mumkin | + +### Massivlarni saralash algoritmlarining murakkabligi + +| Nomi | Eng yaxshi | O'rta | Eng yomon | Xotira | Barqaror | Izohlar | +| ------------------------- | :-----------: | :---------------------: | :-------------------------: | :----: | :------: | :--------------------------------------------------------------------------- | +| **Pufakcha tartiblash** | n | n2 | n2 | 1 | Ha | | +| **Kiritish tartibi** | n | n2 | n2 | 1 | Ha | | +| **Tanlash tartibi** | n2 | n2 | n2 | 1 | Yo'q | | +| **Heap tartibi** | n log(n) | n log(n) | n log(n) | 1 | Yo'q | | +| **Birlashtirish tartibi** | n log(n) | n log(n) | n log(n) | n | Ha | | +| **Tezkor saralash** | n log(n) | n log(n) | n2 | log(n) | Yo'q | Tezkor saralash odatda O(log(n)) stek maydoni bilan joyida amalga oshiriladi | +| **Shell tartiblash** | n log(n) | depends on gap sequence | n (log(n))2 | 1 | Yo'q | | +| **Sanash tartibi** | n + r | n + r | n + r | n + r | Ha | r - massivdagi eng katta raqam | +| **Radiksli tartiblash** | n \* k | n \* k | n \* k | n + k | Ha | k - eng uzun kalitning uzunligi | + +## Loyihani qo'llab-quvvatlovchilar + +> Siz ushbu loyihani ❤️️ [GitHub](https://github.com/sponsors/trekhleb) yoki ❤️️ [Patreon](https://www.patreon.com/trekhleb) orqali qo'llab-quvvatlashingiz mumkin. + +[Ushbu loyihani qo'llab-quvvatlagan odamlar](https://github.com/trekhleb/javascript-algorithms/blob/master/BACKERS.md) `∑ = 1` + +## Muallif + +[@trekhleb](https://trekhleb.dev) + +A few more [projects](https://trekhleb.dev/projects/) and [articles](https://trekhleb.dev/blog/) about JavaScript and algorithms on [trekhleb.dev](https://trekhleb.dev) diff --git a/README.zh-CN.md b/README.zh-CN.md index cdef9cab..27982c65 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -23,7 +23,8 @@ _Read this in other languages:_ [_Українська_](README.uk-UA.md), [_Arabic_](README.ar-AR.md), [_Tiếng Việt_](README.vi-VN.md), -[_Deutsch_](README.de-DE.md) +[_Deutsch_](README.de-DE.md), +[_Uzbek_](README.uz-UZ.md) *注意:这个项目仅用于学习和研究,**不是**用于生产环境。* diff --git a/README.zh-TW.md b/README.zh-TW.md index 20d4381a..aeb0547d 100644 --- a/README.zh-TW.md +++ b/README.zh-TW.md @@ -22,7 +22,8 @@ _Read this in other languages:_ [_Українська_](README.uk-UA.md), [_Arabic_](README.ar-AR.md), [_Tiếng Việt_](README.vi-VN.md), -[_Deutsch_](README.de-DE.md) +[_Deutsch_](README.de-DE.md), +[_Uzbek_](README.uz-UZ.md) ## 資料結構 From 09afeb58d820ae32d6f3ccfa4042981fae4e1a9d Mon Sep 17 00:00:00 2001 From: Stanislav Dolgachov Date: Sat, 13 Jul 2024 22:13:11 +0300 Subject: [PATCH 04/11] Update .eslintrc, improve UK translation for LinkedList (#1128) * Add ignore patterns to eslint config * Improve UK translation for LinkedList --------- Co-authored-by: Oleksii Trekhleb <3000285+trekhleb@users.noreply.github.com> --- .eslintrc | 1 + .../linked-list/README.uk-UA.md | 26 +++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.eslintrc b/.eslintrc index cf3245bf..88af3ecf 100644 --- a/.eslintrc +++ b/.eslintrc @@ -12,6 +12,7 @@ "arrow-body-style": "off", "no-loop-func": "off" }, + "ignorePatterns": ["*.md", "*.png", "*.jpeg", "*.jpg"], "settings": { "react": { "version": "18.2.0" diff --git a/src/data-structures/linked-list/README.uk-UA.md b/src/data-structures/linked-list/README.uk-UA.md index 5424c58d..9b34a6d8 100644 --- a/src/data-structures/linked-list/README.uk-UA.md +++ b/src/data-structures/linked-list/README.uk-UA.md @@ -1,10 +1,10 @@ # Зв'язаний список -Зв'язаний список — базова динамічна структура даних в інформатиці, що складається з вузлів, кожен з яких містить як дані, так посилання («зв'язку») на наступний вузол списку. Дана структура дозволяє ефективно додавати та видаляти елементи на довільній позиції у послідовності у процесі ітерації. Більш складні варіанти включають додаткові посилання, що дозволяють ефективно додавати та видаляти довільні елементи. +Зв'язаний список — базова динамічна структура даних в інформатиці, що складається з вузлів, кожен з яких містить як дані, так і посилання («зв'язку») на наступний вузол списку. Ця структура даних дозволяє ефективно додавати та видаляти елементи на довільній позиції у послідовності у процесі ітерації. Більш складні варіанти включають додаткові посилання, що дозволяють ефективно додавати та видаляти довільні елементи. -Принциповою перевагою перед масивом є структурна гнучкість: порядок елементів зв'язкового списку може збігатися з порядком розташування елементів даних у пам'яті комп'ютера, а порядок обходу списку завжди явно задається його внутрішніми зв'язками. Суть переваги у тому, що у багатьох мовах створення масиву вимагає вказати його заздалегідь. Зв'язковий список дозволяє обійти це обмеження. +Принциповою перевагою перед масивом є структурна гнучкість: порядок елементів зв'язаного списку може збігатися з порядком розташування елементів даних у пам'яті комп'ютера, а порядок обходу списку завжди явно задається його внутрішніми зв'язками. Це важливо, бо у багатьох мовах створення масиву вимагає вказати його розмір заздалегідь. Зв'язаний список дозволяє обійти це обмеження. -Недоліком зв'язкових списків є те, що час доступу є лінійним (і важко для реалізації конвеєрів). Неможливий швидкий доступ (випадковий). +Недоліком зв'язаних списків є те, що час доступу є лінійним (і важко для реалізації конвеєрів). Неможливий швидкий доступ (випадковий). ![Linked List](./images/linked-list.jpeg) @@ -17,7 +17,7 @@ ```text Add(value) Pre: value - значення, що додається - Post: value поміщено в кінець списку + Post: value додано в кінець списку n ← node(value) if head = ø head ← n @@ -32,7 +32,7 @@ end Add ```text Prepend(value) Pre: value - значення, що додається - Post: value поміщено на початок списку + Post: value додано на початку списку n ← node(value) n.next ← head head ← n @@ -42,7 +42,7 @@ Prepend(value) end Prepend ``` -### Поиск +### Пошук ```text Contains(head, value) @@ -60,7 +60,7 @@ Contains(head, value) end Contains ``` -### Вилучення +### Видалення ```text Remove(head, value) @@ -94,7 +94,7 @@ Remove(head, value) end Remove ``` -### Обход +### Обхід ```text Traverse(head) @@ -108,12 +108,12 @@ Traverse(head) end Traverse ``` -### Зворотний обхід +### Зворотній обхід ```text ReverseTraversal(head, tail) - Pre: head и tail відносяться до одного списку - Post: елементи списку пройдено у зворотному порядку + Pre: head і tail відносяться до одного списку + Post: елементи списку пройдено у зворотньому порядку if tail != ø curr ← tail while curr != head @@ -131,7 +131,7 @@ end ReverseTraversal ## Складність -### Тимчасова складність +### Часова складність | Читання | Пошук | Вставка | Вилучення | | :--------: | :-------: | :--------: | :-------: | @@ -143,5 +143,5 @@ O(n) ## Посилання -- [Wikipedia](https://uk.wikipedia.org/wiki/%D0%97%D0%B2%27%D1%8F%D0%B7%D0%B0%D0%BD%D0%B8%D0%B9_%D1%81%D0%BF%D0%B8%D1%81%D0%BE%D0%BA) +- [Wikipedia](https://uk.wikipedia.org/wiki/Зв'язаний_список) - [YouTube](https://www.youtube.com/watch?v=6snsMa4E1Os) From 6509304ff613f88191155f1f9834aace8db1c149 Mon Sep 17 00:00:00 2001 From: JungHyunLah Date: Sun, 14 Jul 2024 04:20:23 +0900 Subject: [PATCH 05/11] update LRU Cache translation for ko-KR (#987) * feat: LRU cache translation in ko-KR * chore: add readInAnotherLan for ko-KR --------- Co-authored-by: Oleksii Trekhleb <3000285+trekhleb@users.noreply.github.com> --- src/data-structures/lru-cache/README.ko-KR.md | 51 +++++++++++++++++++ src/data-structures/lru-cache/README.md | 15 +++--- 2 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 src/data-structures/lru-cache/README.ko-KR.md diff --git a/src/data-structures/lru-cache/README.ko-KR.md b/src/data-structures/lru-cache/README.ko-KR.md new file mode 100644 index 00000000..93957bc0 --- /dev/null +++ b/src/data-structures/lru-cache/README.ko-KR.md @@ -0,0 +1,51 @@ +# LRU 캐시 알고리즘 + +**LRU 캐시 알고리즘** 은 사용된 순서대로 아이템을 정리함으로써, 오랜 시간 동안 사용되지 않은 아이템을 빠르게 찾아낼 수 있도록 한다. + +한방향으로만 옷을 걸 수 있는 옷걸이 행거를 생각해봅시다. 가장 오랫동안 입지 않은 옷을 찾기 위해서는, 행거의 반대쪽 끝을 보면 됩니다. + +## 문제 정의 + +LRUCache 클래스를 구현해봅시다: + +- `LRUCache(int capacity)` LRU 캐시를 **양수** 의 `capacity` 로 초기화합니다. +- `int get(int key)` `key` 가 존재할 경우 `key` 값을 반환하고, 그렇지 않으면 `undefined` 를 반환합니다. +- `void set(int key, int value)` `key` 가 존재할 경우 `key` 값을 업데이트 하고, 그렇지 않으면 `key-value` 쌍을 캐시에 추가합니다. 만약 이 동작으로 인해 키 개수가 `capacity` 를 넘는 경우, 가장 오래된 키 값을 **제거** 합니다. + +`get()` 과 `set()` 함수는 무조건 평균 `O(1)` 의 시간 복잡도 내에 실행되어야 합니다. + +## 구현 + +### 버전 1: 더블 링크드 리스트 + 해시맵 + +[LRUCache.js](./LRUCache.js) 에서 `LRUCache` 구현체 예시를 확인할 수 있습니다. 예시에서는 (평균적으로) 빠른 `O(1)` 캐시 아이템 접근을 위해 `HashMap` 을 사용했고, (평균적으로) 빠른 `O(1)` 캐시 아이템 수정과 제거를 위해 `DoublyLinkedList` 를 사용했습니다. (허용된 최대의 캐시 용량을 유지하기 위해) + +![Linked List](./images/lru-cache.jpg) + +_[okso.app](https://okso.app) 으로 만듦_ + +LRU 캐시가 어떻게 작동하는지 더 많은 예시로 확인하고 싶다면 LRUCache.test.js](./**test**/LRUCache.test.js) 파일을 참고하세요. + +### 버전 2: 정렬된 맵 + +더블 링크드 리스트로 구현한 첫번째 예시는 어떻게 평균 `O(1)` 시간 복잡도가 `set()` 과 `get()` 으로 나올 수 있는지 학습 목적과 이해를 돕기 위해 좋은 예시입니다. + +그러나, 더 쉬운 방법은 자바스크립트의 [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) 객체를 사용하는 것입니다. 이 `Map` 객체는 키-값 쌍과 키를 **추가하는 순서 원본** 을 지닙니다. 우리는 이걸 아이템을 제거하거나 다시 추가하면서 맵의 "가장 마지막" 동작에서 최근에 사용된 아이템을 유지하기 위해 사용할 수 있습니다. `Map` 의 시작점에 있는 아이템은 캐시 용량이 넘칠 경우 가장 먼저 제거되는 대상입니다. 아이템의 순서는 `map.keys()` 와 같은 `IterableIterator` 을 사용해 확인할 수 있습니다. + +해당 구현체는 [LRUCacheOnMap.js](./LRUCacheOnMap.js) 의 `LRUCacheOnMap` 예시에서 확인할 수 있습니다. + +이 LRU 캐시 방식이 어떻게 작동하는지 더 많은 테스트 케이스를 확인하고 싶다면 [LRUCacheOnMap.test.js](./__test__/LRUCacheOnMap.test.js) 파일을 참고하세요. + +## 복잡도 + +| | 평균 | +| --------------- | ------ | +| 공간 | `O(n)` | +| 아이템 찾기 | `O(1)` | +| 아이템 설정하기 | `O(1)` | + +## 참조 + +- [LRU Cache on LeetCode](https://leetcode.com/problems/lru-cache/solutions/244744/lru-cache/) +- [LRU Cache on InterviewCake](https://www.interviewcake.com/concept/java/lru-cache) +- [LRU Cache on Wiki](https://en.wikipedia.org/wiki/Cache_replacement_policies) diff --git a/src/data-structures/lru-cache/README.md b/src/data-structures/lru-cache/README.md index 05bcc0a0..eaa075f8 100644 --- a/src/data-structures/lru-cache/README.md +++ b/src/data-structures/lru-cache/README.md @@ -1,5 +1,8 @@ # Least Recently Used (LRU) Cache +_Read this in other languages:_ +[한국어](README.ko-KR.md), + A **Least Recently Used (LRU) Cache** organizes items in order of use, allowing you to quickly identify which item hasn't been used for the longest amount of time. Picture a clothes rack, where clothes are always hung up on one side. To find the least-recently used item, look at the item on the other end of the rack. @@ -22,7 +25,7 @@ See the `LRUCache` implementation example in [LRUCache.js](./LRUCache.js). The s ![Linked List](./images/lru-cache.jpg) -*Made with [okso.app](https://okso.app)* +_Made with [okso.app](https://okso.app)_ You may also find more test-case examples of how the LRU Cache works in [LRUCache.test.js](./__test__/LRUCache.test.js) file. @@ -38,11 +41,11 @@ You may also find more test-case examples of how the LRU Cache works in [LRUCach ## Complexities -| | Average | -|---|---| -| Space |`O(n)`| -| Get item | `O(1)` | -| Set item | `O(1)` | +| | Average | +| -------- | ------- | +| Space | `O(n)` | +| Get item | `O(1)` | +| Set item | `O(1)` | ## References From 0c054f782aa57f4dbc56975452406b73cba8dc09 Mon Sep 17 00:00:00 2001 From: Youssef Rabei Date: Sat, 13 Jul 2024 22:22:10 +0300 Subject: [PATCH 06/11] Update README.ar-AR.md (#959) Co-authored-by: Oleksii Trekhleb <3000285+trekhleb@users.noreply.github.com> --- README.ar-AR.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.ar-AR.md b/README.ar-AR.md index fedd29c0..81c9c91a 100644 --- a/README.ar-AR.md +++ b/README.ar-AR.md @@ -3,7 +3,7 @@ [![Build Status](https://travis-ci.org/trekhleb/javascript-algorithms.svg?branch=master)](https://travis-ci.org/trekhleb/javascript-algorithms) [![codecov](https://codecov.io/gh/trekhleb/javascript-algorithms/branch/master/graph/badge.svg)](https://codecov.io/gh/trekhleb/javascript-algorithms) -تحتوي هذا مقالة على أمثلة عديدة تستند إلى الخوارزميات الشائعة وهياكل البيانات في الجافا سكريبت. +تحتوي هذه المقالة على أمثلة عديدة تستند إلى الخوارزميات الشائعة وهياكل البيانات في الجافا سكريبت. كل خوارزمية وهياكل البيانات لها برنامج README منفصل خاص بها مع التفسيرات والروابط ذات الصلة لمزيد من القراءة (بما في ذلك تلك From 0e2b2574f83d94adfe5822b1f09203ee60a34a31 Mon Sep 17 00:00:00 2001 From: Nikita Gurskiy <85452618+lilipops@users.noreply.github.com> Date: Sat, 13 Jul 2024 21:23:02 +0200 Subject: [PATCH 07/11] update the ES README a lenguage correction (#952) --- README.es-ES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.es-ES.md b/README.es-ES.md index 24d1990a..e6879a19 100644 --- a/README.es-ES.md +++ b/README.es-ES.md @@ -70,7 +70,7 @@ definen con precisión una secuencia de operaciones. * **Matemáticas** * `P` [Manipulación de bits](src/algorithms/math/bits) - asignar/obtener/actualizar/limpiar bits, multiplicación/división por dos, hacer negativo, etc. * `P` [Factorial](src/algorithms/math/factorial) - * `P` [Número de Fibonacci](src/algorithms/math/fibonacci) + * `P` [Sucesión de Fibonacci](src/algorithms/math/fibonacci) * `P` [Prueba de primalidad](src/algorithms/math/primality-test) (método de división de prueba) * `P` [Algoritmo de Euclides](src/algorithms/math/euclidean-algorithm) - calcular el Máximo común divisor (MCD) * `P` [Mínimo común múltiplo](src/algorithms/math/least-common-multiple) (MCM) From 351a63a59fdea2e27eb69d50be897c7416a5951a Mon Sep 17 00:00:00 2001 From: Alaz Tetik Date: Sat, 13 Jul 2024 22:25:58 +0300 Subject: [PATCH 08/11] Update README.md by correcting Turkish lang name (#904) Co-authored-by: Oleksii Trekhleb <3000285+trekhleb@users.noreply.github.com> From 471e6d0791167756d0a7f35a2a197e235bca73f7 Mon Sep 17 00:00:00 2001 From: Enzo Date: Sat, 13 Jul 2024 15:27:09 -0400 Subject: [PATCH 09/11] Add es-ES translation to search/binary-search (#893) --- .../search/binary-search/README.es-ES.md | 27 +++++++++++++++++++ src/algorithms/search/binary-search/README.md | 17 ++++++------ .../search/binary-search/README.pt-BR.md | 1 + 3 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 src/algorithms/search/binary-search/README.es-ES.md diff --git a/src/algorithms/search/binary-search/README.es-ES.md b/src/algorithms/search/binary-search/README.es-ES.md new file mode 100644 index 00000000..f14aef98 --- /dev/null +++ b/src/algorithms/search/binary-search/README.es-ES.md @@ -0,0 +1,27 @@ +# Búsqueda binaria + +_Lea esto en otros idiomas:_ +[English](README.md) +[Português brasileiro](README.pt-BR.md). + +En informática, la búsqueda binaria, también conocida como búsqueda de medio intervalo +búsqueda, búsqueda logarítmica, o corte binario, es un algoritmo de búsqueda +que encuentra la posición de un valor objetivo dentro de una matriz +ordenada. La búsqueda binaria compara el valor objetivo con el elemento central +de la matriz; si son desiguales, se elimina la mitad en la que +la mitad en la que no puede estar el objetivo se elimina y la búsqueda continúa +en la mitad restante hasta que tenga éxito. Si la búsqueda +termina con la mitad restante vacía, el objetivo no está +en la matriz. + +![Búsqueda binaria](https://upload.wikimedia.org/wikipedia/commons/8/83/Binary_Search_Depiction.svg) + +## Complejidad + +**Complejidad de tiempo**: `O(log(n))` - ya que dividimos el área de búsqueda en dos para cada +siguiente iteración. + +## Referencias + +- [Wikipedia](https://en.wikipedia.org/wiki/Binary_search_algorithm) +- [YouTube](https://www.youtube.com/watch?v=P3YID7liBug&index=29&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8) diff --git a/src/algorithms/search/binary-search/README.md b/src/algorithms/search/binary-search/README.md index ebf3e123..34d1bd7a 100644 --- a/src/algorithms/search/binary-search/README.md +++ b/src/algorithms/search/binary-search/README.md @@ -2,15 +2,16 @@ _Read this in other languages:_ [Português brasileiro](README.pt-BR.md). +[Español](README.es-ES.md). -In computer science, binary search, also known as half-interval -search, logarithmic search, or binary chop, is a search algorithm -that finds the position of a target value within a sorted -array. Binary search compares the target value to the middle -element of the array; if they are unequal, the half in which -the target cannot lie is eliminated and the search continues -on the remaining half until it is successful. If the search -ends with the remaining half being empty, the target is not +In computer science, binary search, also known as half-interval +search, logarithmic search, or binary chop, is a search algorithm +that finds the position of a target value within a sorted +array. Binary search compares the target value to the middle +element of the array; if they are unequal, the half in which +the target cannot lie is eliminated and the search continues +on the remaining half until it is successful. If the search +ends with the remaining half being empty, the target is not in the array. ![Binary Search](https://upload.wikimedia.org/wikipedia/commons/8/83/Binary_Search_Depiction.svg) diff --git a/src/algorithms/search/binary-search/README.pt-BR.md b/src/algorithms/search/binary-search/README.pt-BR.md index 14445a04..4f9de9f1 100644 --- a/src/algorithms/search/binary-search/README.pt-BR.md +++ b/src/algorithms/search/binary-search/README.pt-BR.md @@ -2,6 +2,7 @@ _Leia isso em outras línguas:_ [english](README.md). +[Español](README.es-ES.md). Em ciência da computação, busca binária, também conhecida como busca de meio-intervalo, busca logarítmica ou corte binário, é um algoritmo de pesquisa que encontra a posição de um elemento alvo dentro de um From e7f30a7bf76ffcbcd37a3163f2a5c8f346aea2e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicente=20Guti=C3=A9rrez?= Date: Sat, 13 Jul 2024 13:28:02 -0600 Subject: [PATCH 10/11] Fix typos README.es-ES for linked list (#850) --- src/data-structures/linked-list/README.es-ES.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/data-structures/linked-list/README.es-ES.md b/src/data-structures/linked-list/README.es-ES.md index c21c48cd..6c6ba7ee 100644 --- a/src/data-structures/linked-list/README.es-ES.md +++ b/src/data-structures/linked-list/README.es-ES.md @@ -7,9 +7,9 @@ _Lee este artículo en otros idiomas:_ [_Português_](README.pt-BR.md) [_English_](README.md) -En ciencias de la computaciòn una **lista enlazada** es una coleccion linear -de elementos de datos, en los cuales el orden linear no es dado por -su posciòn fisica en memoria. En cambio, cada +En ciencias de la computación una **lista enlazada** es una colección lineal +de elementos, en los cuales el orden lineal no es dado por +su posición física en memoria. En cambio, cada elemento señala al siguiente. Es una estructura de datos que consiste en un grupo de nodos los cuales juntos representan una secuencia. En su forma más sencilla, cada nodo está @@ -19,10 +19,10 @@ permite la inserción o eliminación de elementos desde cualquier posición en la secuencia durante la iteración. Las variantes más complejas agregan enlaces adicionales, permitiendo una eficiente inserción o eliminación desde referencias arbitrarias -del elemento. Una desventaja de las listas lazadas es que el tiempo de +del elemento. Una desventaja de las listas enlazadas es que el tiempo de acceso es lineal (y difícil de canalizar). Un acceso más rápido, como un acceso aleatorio, no es factible. Los arreglos -tienen una mejor locazion en caché comparados con las listas lazadas. +tienen una mejor localización en caché comparados con las listas enlazadas. ![Linked List](./images/linked-list.jpeg) @@ -112,7 +112,7 @@ Remove(head, value) end Remove ``` -### Atrevesar +### Atravesar ```text Traverse(head) From ca3d16dcce7a493ae12c03ca20ede4fd7801f7a2 Mon Sep 17 00:00:00 2001 From: Vlad Sosnov Date: Sat, 13 Jul 2024 21:28:34 +0200 Subject: [PATCH 11/11] Update README.uk-UA.md (#991) Co-authored-by: Oleksii Trekhleb <3000285+trekhleb@users.noreply.github.com> --- src/data-structures/stack/README.uk-UA.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/data-structures/stack/README.uk-UA.md b/src/data-structures/stack/README.uk-UA.md index 9941114f..f71d2274 100644 --- a/src/data-structures/stack/README.uk-UA.md +++ b/src/data-structures/stack/README.uk-UA.md @@ -10,8 +10,8 @@ Додаткова операція для читання головного елемента (peek) дає доступ до останнього елементу стека без зміни самого стека. -Найчастіше принцип роботи стека порівнюють зі чаркою тарілок: щоб узяти другу -зверху потрібно зняти верхню. +Найчастіше принцип роботи стека порівнюють із стопкою тарілок: щоб узяти другу +зверху потрібно спочатку зняти верхню. Ілюстрація роботи зі стеком.