306 Commits

Author SHA1 Message Date
RyanM-Dev
b3dbf79d05 Added my simpler implementation for the recursive max function (#300) 2025-05-01 18:32:08 -05:00
Christine P. Chai
ceea225d2e added selection sort for R (#301) 2025-05-01 18:30:45 -05:00
Marco Milanesi
f6932eebaa Add elixir longest common subsequence implementation (#306) 2025-05-01 18:30:12 -05:00
Christine P. Chai
5bbef9bce7 Update .gitignore (#302)
Added Python and R specific parts to .gitignore
2025-05-01 18:25:36 -05:00
Vladyslav
9ed0658636 Fix typo in variable name in selection sort example (#304) 2025-05-01 18:25:03 -05:00
Serg Gini
9ff7468e9e D solutions (#305)
* Added 1 and 2 chapters

for D lang

* [D] Added recursion code

All examples were ported from the Python code directly to D.
Naming convention of Dlang is not allowing to run code files, which started with numbers. To run examples rename the files

* [D] quicksort code

* [D] Added hashtable example

Based on the Python code

* Create 01_breadth_first_search.d

Added D example for breadth-first search

* Create 01_filesystem_dfs.d

Filesystem example in D

* Create 01_dijkstras_algorithm.d

Added Dijkstras algorithm implementation for D

* Create 01_set_covering.d

Added greedy algorythm for D

* Create 01_longest_common_sub.d

Added dynamic programming example for D language.
The code is based on Rust example

* Added modules definition

Required to run code with names starting with numbers

* Fixed proper unsigned handling
2025-05-01 18:24:42 -05:00
Marco Milanesi
df180e6f7b Add elixir longest common substring implementation (#307) 2025-05-01 18:23:06 -05:00
Igor Moraes
182947e5fb Add TypeScript examples for chapters 10 and 11 (#311) 2025-05-01 18:22:19 -05:00
Artem Chernyak
a9d98d826a add rust quicksort (#292)
* add rust quicksort

* remove binary search from quicksort
2024-12-15 19:35:58 -06:00
Aditya Bhargava
1de675efe1 Contributing guidelines update 2024-12-07 08:28:56 -06:00
Timur Sevimli
45bf3c086d Increase readability, update code style and optimise for modern JavaScript (#273)
* Remove loops on recursive example, increase readability and optimise

* Update style and optimise

* Update 01_loop_sum_reduce_version.js

Update style

* Update style

* Rename identificators

* Rename identificators

* Convert shift to splice
2024-12-07 07:48:14 -06:00
Mahmoud Hamdy
c06ad954f0 Update 01_binary_search.cpp (#271)
use template to the item that we are search for
2024-12-07 07:45:03 -06:00
Poliakov Ilia
00b28478ce Update 04_recursive_max.js with fix for alternative solution (#262)
* Update 04_recursive_max.js with fix for alternative solution

Current alternative solution works only for arrays of natural numbers and for empty arrays it returns 0 instead of null or Error. This commit fixes these problems.

* Considering comments from the author

---------

Co-authored-by: Ilia Poliakov <ilia.poliakov@macys.com>
2024-12-07 07:44:23 -06:00
Toheeb Oyekola
440db4ff11 Added sum with recursion to 03_recursion, java folder (#254)
* added sum with recursion to 03_recursion, java folder

* Update .gitignore

* update list not to be modified during recursion

* fixed update
2024-12-07 07:43:11 -06:00
Ismayil Mammadov
22c23551cb Added 01_filesystem_dfs for 07_trees in C# (#299) 2024-12-07 07:40:21 -06:00
Armin
c8ff601c52 feat: enhance recursive binary search to correctly return found index (#298)
Co-authored-by: armin <armin.eyvazi@snappshop.ir>
2024-12-07 07:39:40 -06:00
Artem Chernyak
f4910688db add dynamic programming examples in rust (#296) 2024-12-07 07:38:07 -06:00
Artem Chernyak
25b308ff5f add greedy algorithms example in rust (#295) 2024-12-07 07:37:26 -06:00
Artem Chernyak
93a7b227b3 add dijkstra's algorithm in rust (#294) 2024-12-07 07:36:57 -06:00
Artem Chernyak
741c11bac6 add rust breadth first search (#293) 2024-12-07 07:36:33 -06:00
Renan Duarte Leal
add60334fb Add Dijkstra's algorithm to Typescript (#291) 2024-12-07 07:34:16 -06:00
Renan Duarte Leal
1d5567fe9a Update 02_check_voter.go (#288)
fix voting status
2024-12-07 07:30:04 -06:00
Paolo Grisoli
8a13efde83 Update examples for Zig (#287)
* update zig in chapters 1-6

* fix zig dijkstras algo

* fix zig greedy algo

* fix longest_common_subsequence in zig

* cleanup

* test: use testing allocator
2024-12-07 07:29:48 -06:00
Christine P. Chai
177581a9a4 Removed a comment with Chinese characters (#283)
Removed a comment with Chinese characters
2024-12-07 07:27:24 -06:00
Punpun
9d20fbff37 Add recursive example for finding a key in nested boxes (Python) (#290) 2024-09-10 16:47:59 -05:00
Aditya Bhargava
775022b848 typo 2024-03-22 15:10:42 -05:00
ViMaCode
f7ccf02e00 Array variable (#259)
The array is set in one place.
2024-03-22 15:10:02 -05:00
Yi-Jen Chen
256625afd7 fix recursive solution for binary search in python (#279) 2024-03-22 15:06:55 -05:00
gweno
cfb59254fb 04 recursive_max in C (#278) 2024-03-22 15:04:27 -05:00
spainn
11a2de7473 Update 01_longest_common_subsequence.py (#277)
The original code was creating a 4x5 grid instead of 5x4.  I also made it display by row.

Co-authored-by: WhileRested <148598154+WhileRested@users.noreply.github.com>
2024-03-22 15:03:28 -05:00
spainn
5d068870bf Update 02_longest_common_substring.py (#276)
The original code did not work correctly out of the box.  It generated a (4,5) grid instead of a (5,4) grid as the book's answer grid shows.  Also on line 10 of my code I changed `dp_table[i-1][i-1] + 1` to `dp_table[i-1][j-1] +1`.  I also updated the display to display by row.

Co-authored-by: WhileRested <148598154+WhileRested@users.noreply.github.com>
2024-03-22 15:02:03 -05:00
Mikhail
7d16656674 Add a solution to the problem on Kotlin (#269)
* Solution. Longest Common Subsequence
2024-03-22 14:51:00 -05:00
Mikhail
cf6b035069 Add Dijkstra's algorithm to Kotlin (#268) 2024-03-22 14:50:11 -05:00
Aditya Bhargava
933acafaf3 reorg and add code for second edition 2023-08-09 08:20:19 -05:00
Adnan
9306432a1b Update 05_quicksort.kt (#267)
remove unnecessary line
2023-08-08 18:11:22 -05:00
Adnan
8969269a10 Update 04_recursive_max.kt (#266)
add an argument to when block
2023-08-08 18:10:53 -05:00
Gabriel Santos
3e99cccfc0 Added Dart examples for chapter 3 to chapter 9 (#265)
* fix: corrected method return value following Dart's newest linter version

* feat: added Dart recursion examples for chapter 3

* feat: added quicksort example in Dart for chapter 4

* feat: added examples in Dart for the chapter 5

* feat: added Dart example for chapter 6 bfs

* feat: added djikstra example in Dart for chapter 7

* feat: added example of set covering in Dart for chapter 8

* feat: added examples for dynamic programming in dart for chapter 9
2023-08-08 18:10:15 -05:00
aestheticw3
182f89b2c4 square brackets fix (#263) 2023-08-08 18:09:34 -05:00
Aslan Autlev
022d97a56d Add examples on scheme. Chapters: 1, 2 (#258)
* add  01_binary_search.scm in 01_introduction_to_algorithms

* any fix

* add 01_selection_sort.scm to 02_selection_sort

* any fix
2023-07-19 10:56:40 -05:00
TheDexire
4dddd5aa83 Update 05_quicksort.swift (#257) 2023-07-19 10:56:17 -05:00
Robson Cruz
7620449322 Added R version of the binary_search function (#253) 2023-07-19 10:53:24 -05:00
Carlos
60b34a01d5 Line removed (#252)
* Added #include <limits.h> to support the use of INT_MAX

* Removed unnecesary (and maybe confusing) initialization of the set
2023-07-19 10:53:01 -05:00
k1borgG
f6cd99c88b Create 04_recursive_max.py (#249)
Problem with max definition. If in input list last element is the biggest, the present algorithm is'n count it. I solved this problem by changing the return in the case if length == 1 from return 1 to first element of list.
2023-07-19 10:51:46 -05:00
Nikita
4d324e464d small refactoring for better code readability (#247) 2023-07-19 10:51:10 -05:00
Alexandr
ed5a723fa5 Csharp updates for 4, 9 chapters (#245)
* GetGCDList fix

* Csharp longest_common_subsequence update

* Csharp levenshtein added

* Couple changes in levenshtein
2023-07-19 10:49:54 -05:00
Pere Frontera
f53fe3b98a SelectionSort csharp using array as input (#226)
Co-authored-by: Pere <pere.frontera@fdsa.es>
2023-07-19 10:49:01 -05:00
Carlos
fa75dc144d Added #include <limits.h> to support the use of INT_MAX (#251) 2023-01-30 10:38:56 -06:00
phunghocong
73e5711b73 Quick_sort_in sorting (#224)
* Update 01_dijkstras_algorithm.go

* Create Test_report.binary_quick_sort.cpp.docx

* 1

fix

* fix it better
2022-11-18 16:52:21 -06:00
Aditya Bhargava
fb4e268804 Merge branch 'quicksort_ES6_examples' of github.com:antonlipilin/grokking_algorithms into antonlipilin-quicksort_ES6_examples 2022-11-18 16:49:48 -06:00
Paolo Grisoli
5d9ae511d5 Add examples for Zig language (#242)
* add zig examples

* improved zig binary search

This commit improves the binary search code in zig. The function has
been made generic and the logic has been cleaned up a bit.
The code has been updated to work with zig versions >= 0.9

* simplify zig selection sort

This commit simplifies the logic of the zig selection sort. It now swaps
in place the elements of the array instead of creating another array.
This avoids allocating heap memory.
The code has also been upgraded to zig version 0.9.1

* make zig recursion examples generic

This commit modifies the zig examples for the recursion chapter to be
generic. It also updates the code to zig version 0.9.1

* update chapter 4 examples

This commit updates the zig examples in chapter 4. In particular
examples have been made generic where possible. The code has been
updated to zig version 0.9.1

* update zig hash table examples

This commit updates the examples for the chapter 5 about hash tables.
Some improvements have been done (using a set instead of a map). The
code has been updated to zig version 0.9.1

* update breadth first search zig example

This commit updates the zig example for the breadth first search
algorithm. It adds a unit test and updates the code to zig version 0.9.1

* revamp zig dijkstra example

* add comments in dijkstra zig

* fix zig greedy algorithm

* add test for zig dijkstra

* add test for zig greedy algorithm

* improve zig chapter 9 exercise

This commit improves the zig exercise to comput the longest common
subsequence.
A main function has been added and the allocator code has been extracted
from the `subsequence` function.
2022-11-18 16:36:32 -06:00