From 826055e51b818d9253632db86db184324257176a Mon Sep 17 00:00:00 2001 From: Aykut <47941171+AykutSarac@users.noreply.github.com> Date: Mon, 2 Nov 2020 20:39:46 +0300 Subject: [PATCH 001/285] Create README.tr-TR.md (#574) Added Turkish language of README.md --- README.tr-TR.md | 317 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 317 insertions(+) create mode 100644 README.tr-TR.md diff --git a/README.tr-TR.md b/README.tr-TR.md new file mode 100644 index 0000000000..fc723e8c76 --- /dev/null +++ b/README.tr-TR.md @@ -0,0 +1,317 @@ +# JavaScript Algoritmalar ve Veri Yapıları + +[![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) + +Bu repository JavaScript'e ait popüler +algoritma ve veri yapılarını içermektedir. + +Her bir algoritma ve veri yapısı kendine +ait açıklama ve videoya sahip README dosyası içerir. + +_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) + +*☝ Not, bu proje araştırma ve öğrenme amacı ile yapılmış +olup üretim için **yaplılmamıştır**.* + +## Veri Yapıları + +A data structure is a particular way of organizing and storing data in a computer so that it can +be accessed and modified efficiently. More precisely, a data structure is a collection of data +values, the relationships among them, and the functions or operations that can be applied to +the data. + + +Bir veri yapısı, verileri bir bilgisayarda organize etmenin ve depolamanın belirli bir yoludur, böylece +verimli bir şekilde erişilebilir ve değiştirilebilir. Daha doğrusu, bir veri yapısı bir veri koleksiyonudur, +aralarındaki ilişkiler, ve işlevler veya işlemler +veriye uygulanabilir. + +`B` - Başlangıç, `A` - İleri Seviye + +* `B` [Bağlantılı Veri Yapısı](src/data-structures/linked-list) +* `B` [Çift Yönlü Bağlı Liste](src/data-structures/doubly-linked-list) +* `B` [Kuyruk](src/data-structures/queue) +* `B` [Yığın](src/data-structures/stack) +* `B` [Hash Table](src/data-structures/hash-table) +* `B` [Heap](src/data-structures/heap) - max and min heap versions +* `B` [Öncelikli Kuyruk](src/data-structures/priority-queue) +* `A` [Trie](src/data-structures/trie) +* `A` [Ağaç](src/data-structures/tree) + * `A` [İkili Arama Ağaçları](src/data-structures/tree/binary-search-tree) + * `A` [AVL Tree](src/data-structures/tree/avl-tree) + * `A` [Red-Black Tree](src/data-structures/tree/red-black-tree) + * `A` [Segment Tree](src/data-structures/tree/segment-tree) - with min/max/sum range queries examples + * `A` [Fenwick Tree](src/data-structures/tree/fenwick-tree) (Binary Indexed Tree) +* `A` [Graph](src/data-structures/graph) (both directed and undirected) +* `A` [Disjoint Set](src/data-structures/disjoint-set) +* `A` [Bloom Filter](src/data-structures/bloom-filter) + +## Algoritmalar + +Bir algoritma, bir problem sınıfının nasıl çözüleceğine dair kesin bir tanımlamadır. Bu +bir işlem dizisini kesin olarak tanımlayan bir dizi kural. + + +`B` - Başlangıç, `A` - İleri Seviye + +### Konusuna göre Algoritma + +* **Matematik** + * `B` [Bit Manipülasyonu](src/algorithms/math/bits) - set/get/update/clear bits, multiplication/division by two, make negative etc. + * `B` [Faktöriyel](src/algorithms/math/factorial) + * `B` [Fibonacci Sayısı](src/algorithms/math/fibonacci) - klasik ve kapalı-form versiyonları + * `B` [Asallık Testi](src/algorithms/math/primality-test) (trial division method) + * `B` [Öklid Algoritması](src/algorithms/math/euclidean-algorithm) - En büyük ortak bölen hesaplama (EBOB) + * `B` [En küçük Ortak Kat](src/algorithms/math/least-common-multiple) (EKOK) + * `B` [Sieve of Eratosthenes](src/algorithms/math/sieve-of-eratosthenes) - belirli bir sayıya kadarki asal sayıları bulma + * `B` [Is Power of Two](src/algorithms/math/is-power-of-two) - sayı ikinin katı mı sorgusu (naive ve bitwise algoritmaları) + * `B` [Paskal Üçgeni](src/algorithms/math/pascal-triangle) + * `B` [Karmaşık Sayılar](src/algorithms/math/complex-number) - karmaşık sayılar ve bunlarla temel işlemler + * `B` [Radyan & Derece](src/algorithms/math/radian) - radyandan dereceye çeviri ve tersi + * `B` [Fast Powering](src/algorithms/math/fast-powering) + * `A` [Tamsayı Bölümü](src/algorithms/math/integer-partition) + * `A` [Karekök](src/algorithms/math/square-root) - Newton yöntemi + * `A` [Liu Hui π Algoritması](src/algorithms/math/liu-hui) - N-gons'a göre yaklaşık π hesabı + * `A` [Ayrık Fourier Dönüşümü](src/algorithms/math/fourier-transform) - bir zaman fonksiyonunu (bir sinyal) onu oluşturan frekanslara ayırır +* **Setler** + * `B` [Kartezyen Ürün](src/algorithms/sets/cartesian-product) - product of multiple sets + * `B` [Fisher–Yates Shuffle](src/algorithms/sets/fisher-yates) - sonlu bir dizinin rastgele permütasyonu + * `A` [Power Set](src/algorithms/sets/power-set) - all subsets of a set (bitwise and backtracking solutions) + * `A` [Permütasyonlar](src/algorithms/sets/permutations)(tekrarlı ve tekrarsız) + * `A` [Kombinasyonlar](src/algorithms/sets/combinations) (tekrarlı ve tekrarsız) + * `A` [En Uzun Ortak Altdizi](src/algorithms/sets/longest-common-subsequence) (LCS) + * `A` [En Uzun Artan Altdizi](src/algorithms/sets/longest-increasing-subsequence) + * `A` [En Kısa Ortak Üst Sıra](src/algorithms/sets/shortest-common-supersequence) (SCS) + * `A` [Knapsack Problem](src/algorithms/sets/knapsack-problem) - "0/1" and "Unbound" ones + * `A` [Maksimum Altdizi](src/algorithms/sets/maximum-subarray) - "Brute Force" ve "Dinamik Programlara" (Kadane'nin) versiyonu + * `A` [Kombinasyon Toplamı](src/algorithms/sets/combination-sum) - belirli toplamı oluşturan tüm kombinasyonları bulun +* **Metin** + * `B` [Hamming Mesafesi](src/algorithms/string/hamming-distance) - sembollerin farklı olduğu konumların sayısı + * `A` [Levenshtein Mesafesi](src/algorithms/string/levenshtein-distance) - iki sekans arasındaki minimum düzenleme mesafesi + * `A` [Knuth–Morris–Pratt Algoritması](src/algorithms/string/knuth-morris-pratt) (KMP Algorithm) - substring search (pattern matching) + * `A` [Z Algoritması](src/algorithms/string/z-algorithm) - altmetin araması (desen eşleştirme) + * `A` [Rabin Karp Algoritması](src/algorithms/string/rabin-karp) - altmetin araması + * `A` [En Uzun Ortak Alt Metin](src/algorithms/string/longest-common-substring) + * `A` [Regular Expression Eşleme](src/algorithms/string/regular-expression-matching) +* **Aramalar** + * `B` [Doğrusal Arama](src/algorithms/search/linear-search) + * `B` [Jump Search](src/algorithms/search/jump-search) (ya da Block Search) - sıralı dizide ara + * `B` [İkili Arama](src/algorithms/search/binary-search) - sıralı dizide ara + * `B` [Interpolation Search](src/algorithms/search/interpolation-search) - tekdüze dağıtılmış sıralı dizide arama +* **Sıralama** + * `B` [Bubble Sort](src/algorithms/sorting/bubble-sort) + * `B` [Selection Sort](src/algorithms/sorting/selection-sort) + * `B` [Insertion Sort](src/algorithms/sorting/insertion-sort) + * `B` [Heap Sort](src/algorithms/sorting/heap-sort) + * `B` [Merge Sort](src/algorithms/sorting/merge-sort) + * `B` [Quicksort](src/algorithms/sorting/quick-sort) - in-place and non-in-place implementations + * `B` [Shellsort](src/algorithms/sorting/shell-sort) + * `B` [Counting Sort](src/algorithms/sorting/counting-sort) + * `B` [Radix Sort](src/algorithms/sorting/radix-sort) +* **Bağlantılı Liste** + * `B` [Straight Traversal](src/algorithms/linked-list/traversal) + * `B` [Reverse Traversal](src/algorithms/linked-list/reverse-traversal) +* **Ağaçlar** + * `B` [Depth-First Search](src/algorithms/tree/depth-first-search) (DFS) + * `B` [Breadth-First Search](src/algorithms/tree/breadth-first-search) (BFS) +* **Graphs** + * `B` [Depth-First Search](src/algorithms/graph/depth-first-search) (DFS) + * `B` [Breadth-First Search](src/algorithms/graph/breadth-first-search) (BFS) + * `B` [Kruskal’s Algorithm](src/algorithms/graph/kruskal) - ağırlıklı yönlendirilmemiş grafik için Minimum Yayılma Ağacı'nı (MST) bulma + * `A` [Dijkstra Algorithm](src/algorithms/graph/dijkstra) - tek tepe noktasından tüm grafik köşelerine en kısa yolları bulmak + * `A` [Bellman-Ford Algorithm](src/algorithms/graph/bellman-ford) - tek tepe noktasından tüm grafik köşelerine en kısa yolları bulmak + * `A` [Floyd-Warshall Algorithm](src/algorithms/graph/floyd-warshall) - tüm köşe çiftleri arasındaki en kısa yolları bulun + * `A` [Detect Cycle](src/algorithms/graph/detect-cycle) - hem yönlendirilmiş hem de yönlendirilmemiş grafikler için (DFS ve Ayrık Küme tabanlı sürümler) + * `A` [Prim’s Algorithm](src/algorithms/graph/prim) - ağırlıklı yönlendirilmemiş grafik için Minimum Yayılma Ağacı'nı (MST) bulma + * `A` [Topological Sorting](src/algorithms/graph/topological-sorting) - DFS metodu + * `A` [Articulation Points](src/algorithms/graph/articulation-points) - Tarjan's algoritması (DFS based) + * `A` [Bridges](src/algorithms/graph/bridges) - DFS yöntemi ile algoritma + * `A` [Eulerian Path and Eulerian Circuit](src/algorithms/graph/eulerian-path) - Fleury'nin algoritması - Her kenara tam olarak bir kez ulaş + * `A` [Hamiltonian Cycle](src/algorithms/graph/hamiltonian-cycle) - Her köşeyi tam olarak bir kez ziyaret et + * `A` [Strongly Connected Components](src/algorithms/graph/strongly-connected-components) - Kosaraju's algorithm + * `A` [Travelling Salesman Problem](src/algorithms/graph/travelling-salesman) - her şehri ziyaret eden ve başlangıç ​​şehrine geri dönen mümkün olan en kısa rota +* **Kriptografi** + * `B` [Polynomial Hash](src/algorithms/cryptography/polynomial-hash) - polinom temelinde dönen hash işlevi + * `B` [Caesar Cipher](src/algorithms/cryptography/caesar-cipher) - simple substitution cipher +* **Makine Öğrenmesi** + * `B` [NanoNeuron](https://github.com/trekhleb/nano-neuron) - 7 simple JS functions that illustrate how machines can actually learn (forward/backward propagation) +* **Kategoriye Ayrılmayanlar** + * `B` [Tower of Hanoi](src/algorithms/uncategorized/hanoi-tower) + * `B` [Square Matrix Rotation](src/algorithms/uncategorized/square-matrix-rotation) - in-place algorithm + * `B` [Jump Game](src/algorithms/uncategorized/jump-game) - backtracking, dynamic programming (top-down + bottom-up) and greedy examples + * `B` [Unique Paths](src/algorithms/uncategorized/unique-paths) - backtracking, dynamic programming and Pascal's Triangle based examples + * `B` [Rain Terraces](src/algorithms/uncategorized/rain-terraces) - trapping rain water problem (dynamic programming and brute force versions) + * `B` [Recursive Staircase](src/algorithms/uncategorized/recursive-staircase) - tepeye ulaşmanın yollarını sayma (4 çözüm) + * `A` [N-Queens Problem](src/algorithms/uncategorized/n-queens) + * `A` [Knight's Tour](src/algorithms/uncategorized/knight-tour) + +### Algoritmik Paradigma + +Algoritmik paradigma, bir sınıfın tasarımının altında yatan genel bir yöntem veya yaklaşımdır. +Algoritma dizayn tekniği olarak düşünülebilir. Her bir altproblemi (subproblem) asıl problemle +benzerlik gösteren problemlere uygulanabilir. + +* **Brute Force** - mümkün olan tüm çözümleri tara ve en iyisini seç + * `B` [Doğrusal Arama](src/algorithms/search/linear-search) + * `B` [Rain Terraces](src/algorithms/uncategorized/rain-terraces) - trapping rain water problem + * `B` [Recursive Staircase](src/algorithms/uncategorized/recursive-staircase) - tepeye çıkmanın yollarını hesapla + * `A` [Maximum Subarray](src/algorithms/sets/maximum-subarray) + * `A` [Travelling Salesman Problem](src/algorithms/graph/travelling-salesman) - her şehri ziyaret eden ve başlangıç şehrine geri dönen mümkün olan en kısa rota + * `A` [Discrete Fourier Transform](src/algorithms/math/fourier-transform) - bir zaman fonksiyonunu (bir sinyal) onu oluşturan frekanslara ayırır +* **Açgözlü** - geleceği düşünmeden şu an için en iyi seçeneği seçin + * `B` [Jump Game](src/algorithms/uncategorized/jump-game) + * `A` [Unbound Knapsack Problem](src/algorithms/sets/knapsack-problem) + * `A` [Dijkstra Algorithm](src/algorithms/graph/dijkstra) - tüm grafik köşelerine giden en kısa yolu bulmak + * `A` [Prim’s Algorithm](src/algorithms/graph/prim) - ağırlıklı yönlendirilmemiş grafik için Minimum Yayılma Ağacı'nı (MST) bulma + * `A` [Kruskal’s Algorithm](src/algorithms/graph/kruskal) - ağırlıklı yönlendirilmemiş grafik için Minimum Yayılma Ağacı'nı (MST) bulma +* **Böl ve Fethet** - sorunu daha küçük parçalara bölün ve sonra bu parçaları çözün + * `B` [Binary Search](src/algorithms/search/binary-search) + * `B` [Tower of Hanoi](src/algorithms/uncategorized/hanoi-tower) + * `B` [Pascal's Triangle](src/algorithms/math/pascal-triangle) + * `B` [Euclidean Algorithm](src/algorithms/math/euclidean-algorithm) - calculate the Greatest Common Divisor (GCD) + * `B` [Merge Sort](src/algorithms/sorting/merge-sort) + * `B` [Quicksort](src/algorithms/sorting/quick-sort) + * `B` [Tree Depth-First Search](src/algorithms/tree/depth-first-search) (DFS) + * `B` [Graph Depth-First Search](src/algorithms/graph/depth-first-search) (DFS) + * `B` [Jump Game](src/algorithms/uncategorized/jump-game) + * `B` [Fast Powering](src/algorithms/math/fast-powering) + * `A` [Permutations](src/algorithms/sets/permutations) (tekrarlı ve tekrarsız) + * `A` [Combinations](src/algorithms/sets/combinations) (tekrarlı ve tekrarsız) +* **Dinamik Programlama** - önceden bulunan alt çözümleri kullanarak bir çözüm oluşturmak + * `B` [Fibonacci Sayısı](src/algorithms/math/fibonacci) + * `B` [Jump Game](src/algorithms/uncategorized/jump-game) + * `B` [Eşsiz Yol](src/algorithms/uncategorized/unique-paths) + * `B` [Rain Terraces](src/algorithms/uncategorized/rain-terraces) - trapping rain water problem + * `B` [Recursive Staircase](src/algorithms/uncategorized/recursive-staircase) - zirveye ulaşmanın yollarının sayısını sayın + * `A` [Levenshtein Distance](src/algorithms/string/levenshtein-distance) - iki sekans arasındaki minimum düzenleme mesafesi + * `A` [Longest Common Subsequence](src/algorithms/sets/longest-common-subsequence) (LCS) + * `A` [Longest Common Substring](src/algorithms/string/longest-common-substring) + * `A` [Longest Increasing Subsequence](src/algorithms/sets/longest-increasing-subsequence) + * `A` [Shortest Common Supersequence](src/algorithms/sets/shortest-common-supersequence) + * `A` [0/1 Knapsack Problem](src/algorithms/sets/knapsack-problem) + * `A` [Integer Partition](src/algorithms/math/integer-partition) + * `A` [Maximum Subarray](src/algorithms/sets/maximum-subarray) + * `A` [Bellman-Ford Algorithm](src/algorithms/graph/bellman-ford) - tüm grafik köşelerine giden en kısa yolu bulmak + * `A` [Floyd-Warshall Algorithm](src/algorithms/graph/floyd-warshall) - tüm köşe çiftleri arasındaki en kısa yolları bulun + * `A` [Regular Expression Matching](src/algorithms/string/regular-expression-matching) +* **Backtracking** - brute forceye benzer, mümkün tüm sonuçları tara, ancak bir sonraki çözümü her ürettiğinizde test edersiniz +tüm koşulları karşılıyorsa ve ancak o zaman sonraki çözümleri üretmeye devam edin. Aksi takdirde, geri dönün ve farklı bir çözüm arayın(?). +Normally the DFS traversal of state-space is being used. + * `B` [Jump Game](src/algorithms/uncategorized/jump-game) + * `B` [Unique Paths](src/algorithms/uncategorized/unique-paths) + * `B` [Power Set](src/algorithms/sets/power-set) - all subsets of a set + * `A` [Hamiltonian Cycle](src/algorithms/graph/hamiltonian-cycle) - Her köşeyi tam olarak bir kez ziyaret edin + * `A` [N-Queens Problem](src/algorithms/uncategorized/n-queens) + * `A` [Knight's Tour](src/algorithms/uncategorized/knight-tour) + * `A` [Combination Sum](src/algorithms/sets/combination-sum) - belirli toplamı oluşturan tüm kombinasyonları bulun +* **Branch & Bound** - remember the lowest-cost solution found at each stage of the backtracking +search, and use the cost of the lowest-cost solution found so far as a lower bound on the cost of +a least-cost solution to the problem, in order to discard partial solutions with costs larger than the +lowest-cost solution found so far. Normally BFS traversal in combination with DFS traversal of state-space +tree is being used. + +## Repository'in Kullanımı + +**Bütün dependencyleri kurun** +``` +npm install +``` + +**ESLint'i başlatın** + +Bunu kodun kalitesini kontrol etmek amacı ile çalıştırabilirsin. + +``` +npm run lint +``` + +**Bütün testleri çalıştır** +``` +npm test +``` + +**Testleri ismine göre çalıştır** +``` +npm test -- 'LinkedList' +``` + +**Deneme Alanı** + +data-structures ve algorithms içerisinde `./src/playground/playground.js` +yazarak `./src/playground/__test__/playground.test.js` için test edebilirsin. + + +Ardından basitçe alttaki komutu girerek kodunun beklendiği gibi çalışıp çalışmadığını test edebilirsin: + +``` +npm test -- 'playground' +``` + +## Yararlı Bilgiler + +### Referanslar + +[▶ Data Structures and Algorithms on YouTube](https://www.youtube.com/playlist?list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8) + +### Big O Notation + +* Big O notation *, algoritmaları, giriş boyutu büyüdükçe çalışma süresi veya alan gereksinimlerinin nasıl arttığına göre sınıflandırmak için kullanılır. +Aşağıdaki grafikte, Big O gösteriminde belirtilen algoritmaların en yaygın büyüme sıralarını bulabilirsiniz. + +![Big O graphs](./assets/big-o-graph.png) + +Kaynak: [Big O Cheat Sheet](http://bigocheatsheet.com/). + +Altta Big O notations ve farklı input boyutlarına karşın yapılmış performans karşılaştırması listelenmektedir. + +| Big O Notation | 10 Element için hesaplama | 100 Element için hesaplama | 1000 Element için hesaplama | +| -------------- | ---------------------------- | ----------------------------- | ------------------------------- | +| **O(1)** | 1 | 1 | 1 | +| **O(log N)** | 3 | 6 | 9 | +| **O(N)** | 10 | 100 | 1000 | +| **O(N log N)** | 30 | 600 | 9000 | +| **O(N^2)** | 100 | 10000 | 1000000 | +| **O(2^N)** | 1024 | 1.26e+29 | 1.07e+301 | +| **O(N!)** | 3628800 | 9.3e+157 | 4.02e+2567 | + +### Veri Yapısı İşlem Karmaşıklığı + +| Veri Yapısı | Access | Search | Insertion | Deletion | Comments | +| ----------------------- | :-------: | :-------: | :-------: | :-------: | :-------- | +| **Dizi** | 1 | n | n | n | | +| **Yığın** | n | n | 1 | 1 | | +| **Sıralı** | n | n | 1 | 1 | | +| **Bağlantılı Liste** | n | n | 1 | n | | +| **Yığın Tablo** | - | n | n | n | Kusursuz hash fonksiyonu durumunda sonuç O(1) | +| **İkili Arama Ağacı** | n | n | n | n | In case of balanced tree costs would be O(log(n)) | +| **B-Tree** | log(n) | log(n) | log(n) | log(n) | | +| **Red-Black Tree** | log(n) | log(n) | log(n) | log(n) | | +| **AVL Tree** | log(n) | log(n) | log(n) | log(n) | | +| **Bloom Filter** | - | 1 | 1 | - | Arama esnasında yanlış sonuçlar çıkabilir | + +### Dizi Sıralama Algoritmaları Karmaşıklığı + +| İsim | En İyi | Ortalama | En Kötü | Hafıza | Kararlı | Yorumlar | +| --------------------- | :-------------: | :-----------------: | :-----------------: | :-------: | :-------: | :-------- | +| **Bubble sort** | n | n2 | n2 | 1 | Evet | | +| **Insertion sort** | n | n2 | n2 | 1 | Evet | | +| **Selection sort** | n2 | n2 | n2 | 1 | Hayır | | +| **Heap sort** | n log(n) | n log(n) | n log(n) | 1 | Hayır | | +| **Merge sort** | n log(n) | n log(n) | n log(n) | n | Evet | | +| **Quick sort** | n log(n) | n log(n) | n2 | log(n) | Hayır | Hızlı sıralama genellikle O(log(n)) yığın alanıyla yapılır | +| **Shell sort** | n log(n) | depends on gap sequence | n (log(n))2 | 1 | Hayır | | +| **Counting sort** | n + r | n + r | n + r | n + r | Evet | r - dizideki en büyük sayı | +| **Radix sort** | n * k | n * k | n * k | n + k | Evet | k - en uzun key'in uzunluğu | + +## Projeyi Destekleme + +Bu projeyi buradan destekleyebilirsiniz ❤️️ [GitHub](https://github.com/sponsors/trekhleb) veya ❤️️ [Patreon](https://www.patreon.com/trekhleb). From ed52a8079e1ad3569782aa9a7cd1fa829d041022 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Mon, 2 Nov 2020 18:44:48 +0100 Subject: [PATCH 002/285] Add links to Turkish README. --- README.es-ES.md | 3 ++- README.fr-FR.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.tr-TR.md | 6 ------ README.zh-CN.md | 3 ++- README.zh-TW.md | 3 ++- 10 files changed, 18 insertions(+), 15 deletions(-) diff --git a/README.es-ES.md b/README.es-ES.md index 76c30b19f8..5f190efc76 100644 --- a/README.es-ES.md +++ b/README.es-ES.md @@ -17,7 +17,8 @@ _Léelo en otros idiomas:_ [_日本語_](README.ja-JP.md), [_Polski_](README.pl-PL.md), [_Français_](README.fr-FR.md), -[_Português_](README.pt-BR.md) +[_Português_](README.pt-BR.md), +[_Türk_](README.tr-TR.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 86a0fad385..f1c79d77a4 100644 --- a/README.fr-FR.md +++ b/README.fr-FR.md @@ -18,7 +18,8 @@ _Lisez ceci dans d'autres langues:_ [_日本語_](README.ja-JP.md), [_Polski_](README.pl-PL.md), [_Español_](README.es-ES.md), -[_Português_](README.pt-BR.md) +[_Português_](README.pt-BR.md), +[_Türk_](README.tr-TR.md) ## Data Structures diff --git a/README.ja-JP.md b/README.ja-JP.md index 144ba508d1..d80e6bfbc7 100644 --- a/README.ja-JP.md +++ b/README.ja-JP.md @@ -17,7 +17,8 @@ _Read this in other languages:_ [_Polski_](README.pl-PL.md), [_Français_](README.fr-FR.md), [_Español_](README.es-ES.md), -[_Português_](README.pt-BR.md) +[_Português_](README.pt-BR.md), +[_Türk_](README.tr-TR.md) ## データ構造 diff --git a/README.ko-KR.md b/README.ko-KR.md index e9b7681f66..2dccf75bd6 100644 --- a/README.ko-KR.md +++ b/README.ko-KR.md @@ -16,7 +16,8 @@ _Read this in other languages:_ [_Polski_](README.pl-PL.md), [_Français_](README.fr-FR.md), [_Español_](README.es-ES.md), -[_Português_](README.pt-BR.md) +[_Português_](README.pt-BR.md), +[_Türk_](README.tr-TR.md) ## 자료 구조 diff --git a/README.md b/README.md index 2a2c50aeea..a438f60696 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,8 @@ _Read this in other languages:_ [_Polski_](README.pl-PL.md), [_Français_](README.fr-FR.md), [_Español_](README.es-ES.md), -[_Português_](README.pt-BR.md) +[_Português_](README.pt-BR.md), +[_Türk_](README.tr-TR.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 4aa25e8d37..f2b76b1dab 100644 --- a/README.pl-PL.md +++ b/README.pl-PL.md @@ -18,7 +18,8 @@ _Read this in other languages:_ [_日本語_](README.ja-JP.md), [_Français_](README.fr-FR.md), [_Español_](README.es-ES.md), -[_Português_](README.pt-BR.md) +[_Português_](README.pt-BR.md), +[_Türk_](README.tr-TR.md) ## Struktury Danych diff --git a/README.pt-BR.md b/README.pt-BR.md index 13087a2dfa..c4d225e025 100644 --- a/README.pt-BR.md +++ b/README.pt-BR.md @@ -18,7 +18,8 @@ _Leia isto em outros idiomas:_ [_日本語_](README.ja-JP.md), [_Polski_](README.pl-PL.md), [_Français_](README.fr-FR.md), -[_Español_](README.es-ES.md) +[_Español_](README.es-ES.md), +[_Türk_](README.tr-TR.md) ## Data Structures diff --git a/README.tr-TR.md b/README.tr-TR.md index fc723e8c76..c0fc6ee18d 100644 --- a/README.tr-TR.md +++ b/README.tr-TR.md @@ -24,12 +24,6 @@ olup üretim için **yaplılmamıştır**.* ## Veri Yapıları -A data structure is a particular way of organizing and storing data in a computer so that it can -be accessed and modified efficiently. More precisely, a data structure is a collection of data -values, the relationships among them, and the functions or operations that can be applied to -the data. - - Bir veri yapısı, verileri bir bilgisayarda organize etmenin ve depolamanın belirli bir yoludur, böylece verimli bir şekilde erişilebilir ve değiştirilebilir. Daha doğrusu, bir veri yapısı bir veri koleksiyonudur, aralarındaki ilişkiler, ve işlevler veya işlemler diff --git a/README.zh-CN.md b/README.zh-CN.md index 6fcbc475aa..cd95bc5c7b 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -15,7 +15,8 @@ _Read this in other languages:_ [_Polski_](README.pl-PL.md), [_Français_](README.fr-FR.md), [_Español_](README.es-ES.md), -[_Português_](README.pt-BR.md) +[_Português_](README.pt-BR.md), +[_Türk_](README.tr-TR.md) *注意:这个项目仅用于学习和研究,**不是**用于生产环境。* diff --git a/README.zh-TW.md b/README.zh-TW.md index 8af7e1fae6..9d7bcb6314 100644 --- a/README.zh-TW.md +++ b/README.zh-TW.md @@ -14,7 +14,8 @@ _Read this in other languages:_ [_Polski_](README.pl-PL.md), [_Français_](README.fr-FR.md), [_Español_](README.es-ES.md), -[_Português_](README.pt-BR.md) +[_Português_](README.pt-BR.md), +[_Türk_](README.tr-TR.md) ## 資料結構 From 83978e9d2d0dc865e18f6d0f3e23a764a49bb193 Mon Sep 17 00:00:00 2001 From: Austin Theriot Date: Sat, 28 Nov 2020 09:35:08 -0600 Subject: [PATCH 003/285] refactored merge sort to use array pointers instead of .shift() (#581) --- .../sorting/merge-sort/MergeSort.js | 54 ++++++++++--------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/src/algorithms/sorting/merge-sort/MergeSort.js b/src/algorithms/sorting/merge-sort/MergeSort.js index 6a2f8a843c..b6eb73f02a 100644 --- a/src/algorithms/sorting/merge-sort/MergeSort.js +++ b/src/algorithms/sorting/merge-sort/MergeSort.js @@ -1,4 +1,4 @@ -import Sort from '../Sort'; +import Sort from "../Sort"; export default class MergeSort extends Sort { sort(originalArray) { @@ -24,36 +24,42 @@ export default class MergeSort extends Sort { } mergeSortedArrays(leftArray, rightArray) { - let sortedArray = []; + const sortedArray = []; - // In case if arrays are not of size 1. - while (leftArray.length && rightArray.length) { - let minimumElement = null; + // Use array pointers to exclude old elements after they have been added to the sorted array + let leftIndex = 0; + let rightIndex = 0; - // Find minimum element of two arrays. - if (this.comparator.lessThanOrEqual(leftArray[0], rightArray[0])) { - minimumElement = leftArray.shift(); - } else { - minimumElement = rightArray.shift(); - } + while (leftIndex < leftArray.length && rightIndex < rightArray.length) { + // Find the minimum element between the left and right array + if ( + this.comparator.lessThanOrEqual( + leftArray[leftIndex], + rightArray[rightIndex] + ) + ) { + sortedArray.push(leftArray[leftIndex]); - // Call visiting callback. - this.callbacks.visitingCallback(minimumElement); + // Increment index pointer to the right + leftIndex += 1; - // Push the minimum element of two arrays to the sorted array. - sortedArray.push(minimumElement); - } + // Call visiting callback. + this.callbacks.visitingCallback(leftArray[leftIndex]); + } else { + sortedArray.push(rightArray[rightIndex]); - // If one of two array still have elements we need to just concatenate - // this element to the sorted array since it is already sorted. - if (leftArray.length) { - sortedArray = sortedArray.concat(leftArray); - } + // Increment index pointer to the right + rightIndex += 1; - if (rightArray.length) { - sortedArray = sortedArray.concat(rightArray); + // Call visiting callback. + this.callbacks.visitingCallback(rightArray[rightIndex]); + } } - return sortedArray; + // There will be one element remaining from either the left OR the right + // Concatenate the remaining element into the sorted array + return sortedArray + .concat(leftArray.slice(leftIndex)) + .concat(rightArray.slice(rightIndex)); } } From 2c74ced8af09e90f60ae45ccbd656e23f3fc64f0 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Sat, 28 Nov 2020 16:43:29 +0100 Subject: [PATCH 004/285] Fix ESLint issues with MergeSort. --- .../sorting/merge-sort/MergeSort.js | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/algorithms/sorting/merge-sort/MergeSort.js b/src/algorithms/sorting/merge-sort/MergeSort.js index b6eb73f02a..23fca74e49 100644 --- a/src/algorithms/sorting/merge-sort/MergeSort.js +++ b/src/algorithms/sorting/merge-sort/MergeSort.js @@ -1,4 +1,4 @@ -import Sort from "../Sort"; +import Sort from '../Sort'; export default class MergeSort extends Sort { sort(originalArray) { @@ -26,38 +26,33 @@ export default class MergeSort extends Sort { mergeSortedArrays(leftArray, rightArray) { const sortedArray = []; - // Use array pointers to exclude old elements after they have been added to the sorted array + // Use array pointers to exclude old elements after they have been added to the sorted array. let leftIndex = 0; let rightIndex = 0; while (leftIndex < leftArray.length && rightIndex < rightArray.length) { - // Find the minimum element between the left and right array - if ( - this.comparator.lessThanOrEqual( - leftArray[leftIndex], - rightArray[rightIndex] - ) - ) { - sortedArray.push(leftArray[leftIndex]); + let minElement = null; + // Find the minimum element between the left and right array. + if (this.comparator.lessThanOrEqual(leftArray[leftIndex], rightArray[rightIndex])) { + minElement = leftArray[leftIndex]; // Increment index pointer to the right leftIndex += 1; - - // Call visiting callback. - this.callbacks.visitingCallback(leftArray[leftIndex]); } else { - sortedArray.push(rightArray[rightIndex]); - + minElement = rightArray[rightIndex]; // Increment index pointer to the right rightIndex += 1; - - // Call visiting callback. - this.callbacks.visitingCallback(rightArray[rightIndex]); } + + // Add the minimum element to the sorted array. + sortedArray.push(minElement); + + // Call visiting callback. + this.callbacks.visitingCallback(minElement); } - // There will be one element remaining from either the left OR the right - // Concatenate the remaining element into the sorted array + // There will be elements remaining from either the left OR the right + // Concatenate the remaining elements into the sorted array return sortedArray .concat(leftArray.slice(leftIndex)) .concat(rightArray.slice(rightIndex)); From 83251dfcdc1bfdb6382f15fd7e1cbbbc207a74ac Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Fri, 4 Dec 2020 18:49:31 +0100 Subject: [PATCH 005/285] Update Backers. --- BACKERS.md | 16 ++++++++++++++-- README.md | 6 ++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/BACKERS.md b/BACKERS.md index 77871fc9a4..1bf4b2cf7c 100644 --- a/BACKERS.md +++ b/BACKERS.md @@ -1,3 +1,15 @@ -# Sponsors & Backers +# Project Backers -Work on this document is in progress... +> You may support this project via ❤️️ [GitHub](https://github.com/sponsors/trekhleb) or ❤️️ [Patreon](https://www.patreon.com/trekhleb). + +## `O(2ⁿ)` Backers + +⏳ + +## `O(n²)` Backers + +⏳ + +## `O(n×log(n))` Backers + +- [bullwinkle](https://github.com/bullwinkle) diff --git a/README.md b/README.md index a438f60696..f54d8aa876 100644 --- a/README.md +++ b/README.md @@ -306,6 +306,8 @@ Below is the list of some of the most used Big O notations and their performance | **Counting sort** | n + r | n + r | n + r | n + r | Yes | r - biggest number in array | | **Radix sort** | n * k | n * k | n * k | n + k | Yes | k - length of longest key | -## Supporting the project +## Project Backers -You may support this project via ❤️️ [GitHub](https://github.com/sponsors/trekhleb) or ❤️️ [Patreon](https://www.patreon.com/trekhleb). +> You may support this project via ❤️️ [GitHub](https://github.com/sponsors/trekhleb) or ❤️️ [Patreon](https://www.patreon.com/trekhleb). + +See the [full list of backers](https://github.com/trekhleb/javascript-algorithms/blob/master/BACKERS.md) From fc1c2d877d909f1c876b4715c7f3bc99b16ee3ae Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Fri, 4 Dec 2020 18:56:25 +0100 Subject: [PATCH 006/285] Update Backers. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f54d8aa876..a17d65901f 100644 --- a/README.md +++ b/README.md @@ -310,4 +310,4 @@ Below is the list of some of the most used Big O notations and their performance > You may support this project via ❤️️ [GitHub](https://github.com/sponsors/trekhleb) or ❤️️ [Patreon](https://www.patreon.com/trekhleb). -See the [full list of backers](https://github.com/trekhleb/javascript-algorithms/blob/master/BACKERS.md) +[Folks that are backing this project](https://github.com/trekhleb/javascript-algorithms/blob/master/BACKERS.md) From 63eebef5de792bfaa1300725bf36169f4cb06f4c Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Fri, 4 Dec 2020 19:00:27 +0100 Subject: [PATCH 007/285] Update Backers. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a17d65901f..f05c93e969 100644 --- a/README.md +++ b/README.md @@ -310,4 +310,4 @@ Below is the list of some of the most used Big O notations and their performance > You may support this project via ❤️️ [GitHub](https://github.com/sponsors/trekhleb) or ❤️️ [Patreon](https://www.patreon.com/trekhleb). -[Folks that are backing this project](https://github.com/trekhleb/javascript-algorithms/blob/master/BACKERS.md) +[**1** folk is backing this project](https://github.com/trekhleb/javascript-algorithms/blob/master/BACKERS.md) From 922b3aeee2ee2863edbd934b5949308f1f80371d Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Fri, 4 Dec 2020 19:14:17 +0100 Subject: [PATCH 008/285] Update Backers. --- BACKERS.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/BACKERS.md b/BACKERS.md index 1bf4b2cf7c..1fcbd42313 100644 --- a/BACKERS.md +++ b/BACKERS.md @@ -12,4 +12,20 @@ ## `O(n×log(n))` Backers -- [bullwinkle](https://github.com/bullwinkle) + + From 7155cfe0e98ac8a394e1f3eac462c9a2dfdaa7a7 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Fri, 4 Dec 2020 19:15:59 +0100 Subject: [PATCH 009/285] Update Backers. --- BACKERS.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/BACKERS.md b/BACKERS.md index 1fcbd42313..7cad14d9b4 100644 --- a/BACKERS.md +++ b/BACKERS.md @@ -17,9 +17,6 @@ @bullwinkle From e5baba45f1be1ad4f0902d0088b7b027529222d5 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Fri, 4 Dec 2020 19:17:06 +0100 Subject: [PATCH 010/285] Update Backers. --- BACKERS.md | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/BACKERS.md b/BACKERS.md index 7cad14d9b4..f9a5bea994 100644 --- a/BACKERS.md +++ b/BACKERS.md @@ -2,14 +2,6 @@ > You may support this project via ❤️️ [GitHub](https://github.com/sponsors/trekhleb) or ❤️️ [Patreon](https://www.patreon.com/trekhleb). -## `O(2ⁿ)` Backers - -⏳ - -## `O(n²)` Backers - -⏳ - ## `O(n×log(n))` Backers From 47b4b686064b0746d2da9bb8dfe7de42430ca565 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Fri, 4 Dec 2020 19:18:34 +0100 Subject: [PATCH 012/285] Update Backers. --- BACKERS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/BACKERS.md b/BACKERS.md index ce6dfc76d9..f9a5bea994 100644 --- a/BACKERS.md +++ b/BACKERS.md @@ -12,6 +12,7 @@ width="30" height="30" /> +   bullwinkle From f1de657bca3c83692a95fe1879ae7c09ad034a28 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Fri, 4 Dec 2020 19:22:49 +0100 Subject: [PATCH 013/285] Update Backers. --- BACKERS.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/BACKERS.md b/BACKERS.md index f9a5bea994..71020a9e99 100644 --- a/BACKERS.md +++ b/BACKERS.md @@ -2,6 +2,14 @@ > You may support this project via ❤️️ [GitHub](https://github.com/sponsors/trekhleb) or ❤️️ [Patreon](https://www.patreon.com/trekhleb). +## `O(2ⁿ)` Backers + +⏳ + +## `O(n²)` Backers + +⏳ + ## `O(n×log(n))` Backers