63 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
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
Artem Chernyak
a9d98d826a add rust quicksort (#292)
* add rust quicksort

* remove binary search from quicksort
2024-12-15 19:35:58 -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
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
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
gweno
cfb59254fb 04 recursive_max in C (#278) 2024-03-22 15:04:27 -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
TheDexire
4dddd5aa83 Update 05_quicksort.swift (#257) 2023-07-19 10:56:17 -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
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
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
kuznevia
1b76ebb2f1 Update 01_loop_sum_reduce_version.js (#235)
changing variables names to correct
2022-11-18 15:48:56 -06:00
David Choi
75e8e8cd9e Update 01_loop_sum_reduce_version.js (#232)
the first parameter of the reduce function is `previousValue` and the second parameter is `currentValue` so these parameter names need to be fixed.
2022-11-18 15:48:41 -06:00
Mikhail Bokov
c91f1ad37f Update 05_quicksort.php (#204) 2022-11-18 15:28:15 -06:00
Rosana Rezende
cf78943cef Update 02_recursive_sum.js (#168)
First, congratulations for the work, the book is very instructive.

In this case, as described in the book, if the list is empty it returns zero, otherwise we apply recursion.

Co-authored-by: Aditya Bhargava <bluemangroupie@gmail.com>
2022-11-18 14:58:08 -06:00
Aditya Bhargava
0292985401 cleaner max function, remove unnecessary duplication 2022-11-18 14:18:55 -06:00
antonlipilin
2080afc740 Add more ES6 examples 2021-10-06 18:20:52 +04:00
Tassadar2499
36accc72c6 F# and C# addings (#189)
* F# - Binary Search

* C# - Double selection sort

* quick sort - f#
2021-03-14 10:43:28 -05:00
Ekram Mohamed
9f330a765a add great common divisor function 2021-02-18 02:02:57 +02:00
Aditya Bhargava
9dae3a4d1c Merge pull request #157 from rusikf/rk/fix_recursive_ruby_max
Fix 04_recursive_max on ruby
2020-09-14 10:53:53 -05:00
Aditya Bhargava
e8a02536f3 Fixed formatting problems, example and JSDoc (#133) 2020-09-14 10:46:57 -05:00
Ruslan Korolev
891eec2873 fix 04_recursive_max on ruby 2020-01-17 18:29:34 +02:00
Massoud Afrashteh
9dc7611411 Julia samples (#108)
* Add julialang binary search sample

* Add unit test

* Add julialang selection sort sample

* Change julia suffix to jl

* Add recursion and quick sort with tests

* add quick sort

* Add hash table samples

* Add BFS

* Changed file names

* Add dijkstras

* Add Dijkstras test
2019-11-12 09:19:21 -06:00
fdrvrtm
30bbe9cf01 Fix the variable typo and add the function call (#109) 2019-11-12 09:19:09 -06:00
Felice Forby
4c3bc702f4 Add recursive binary search for ruby (ch. 1) and improve recursive max for ruby (ch. 4) (#113)
* add recursive binary search for ruby

* account for cases with empty lists and lists with only one item

* use p instead of print to show nil value

* add newline at end of file
2019-11-12 09:18:34 -06:00
Alexandrshy
61b2925a2d Fixed formatting problems, example and JSDoc 2019-07-21 09:05:39 +04:00
Max Beatty
5b675cc2e8 Complete "longest common ..." examples (#100)
* no else return

* fix var ref

* fix importing/requiring dependencies

* complete longest common examples
2019-03-28 14:52:55 -07:00
Alex
d77cde9e67 Add code for chapter 3 and 4 in ts (#103) 2019-03-28 14:51:36 -07:00
Oleg A. Glushko
06ee65d9e5 Please, merge my PowerShell examples for all chapters (#106)
* PowerShell 01_introduction_to_algorithms example

* PowerShell 02_selection_sort example

* PowerShell 03_recursion examples

* PowerShell 04_quicksort examples

* PowerShell 05_hash_tables examples

* PowerShell 06_breadth-first_search example

* PowerShell 07_dijkstras_algorithm example

* PowerShell 08_greedy_algorithms example

* Powershell 09_dynamic_programming example
2019-03-28 14:49:20 -07:00
NikitaLipatov
8a0a191975 03 & 04 exercises (#96) 2018-12-28 08:25:01 -08:00
Johnny Bell
3e887a6d3c updated the 04_quicksort/javascript/01_loop_sum.js to a working soloution (#88) 2018-10-18 08:26:17 -07:00
umatbro
7dc9e95d2a add c++11 (#87)
* binary search c++

* selection sort c++11

* c++ recursive countdown

* c++ recursion

* c++ quicksort

* rename folder names to c++11

* add another version of binary_search function

* c++11 hash tables

* c++11 breadth-first search
2018-10-18 08:25:54 -07:00
Artem Solovev
0d5d0164ce Added more implementations (JS) (#67)
* Added recursive binary search (JS)

* Added recursive selection sorting

* Added another loop implementation sum func by reduce (JS)

* Recursion reduced by one iteration

* Recursive binary search in ES6 added to appropriate folder

* JS files ordered by standards (ES4/ES6)

* Added hashtable implementation in JS

* Fixed typo with LENGTH prop

* Added Euclidian algorithm for two numbers and set of them

* Added universal selection sort

* Commented output

* Added ES6 version of Euclidean algorithm

* Converted from ES6 to ES5

* #69 Added search for LCS

* #69 added levenstein algorithm

* Removed excessive property

* Removed excessive file

* Removed excessive function calls

* Removed excessive file

* Removed excessive file

* Renamed

* Fixed indentation
2018-08-24 11:21:54 -07:00
Evgeny Garlukovich
5d965d0b8a Add Elixir examples for quicksort 2018-04-20 08:18:52 -07:00
Ramit Mittal
2f939182ae Resolve Issue #40: Changed more examples to use python3 syntax (#56) 2018-03-19 09:48:21 -07:00
WangX
3474a1069f Update 04_recursive_max.py (#52)
Avoid error while len(lst) is 0 and 1
2018-02-03 11:57:39 -08:00
Danh Nguyen
1fa164c40e Resolve Issue #40: Python 2 print statements changed to use Python 3 print function (#50)
* Update 01_selection_sort.py

Updated last print statement for Python 3 print function.

* Update 01_countdown.py

Updated print statement to print function for Python 3.

* Update 05_quicksort.py

Updated print statement to print function for Python 3.

* Update 01_price_of_groceries.py

Condensed dictionary creation into one line, edited print statement to a print function for Python 3.

* Update 01_set_covering.py

Changed print statement to print function for Python 3.

* Update 01_binary_search.py

Changed print statements to print function for Python 3.
2018-02-03 11:15:07 -08:00
ryn1x
7d48d29139 add perl6 code for chapters 1-4 (#49) 2018-01-04 06:46:31 -08:00
Dmitrii Rytikov
dd0100e471 fix algoritm (#45) 2017-12-02 12:15:23 -08:00
Seoungtae Kim
3499ab656a golang about 04_quicksort (#43)
* recursion_Golang

* go_fmt

* selection_sort_Golang

* rm-golang

* selection_sort_Golang

* selection_sort_Golang

* selection_sort_Golang

* dynamic_golang

* golang 05_hash_tables 02_check_voter.go

* golang 05_hash_tables 01_price_of_groceries

* add 01_loop_sum in 04_quicksort

* 02_recursive_sum in 04_quicksort

* 03_recursive_count in 04_quicksort

* 04_recursive_max in 04_quicksort

* 05_quicksort in 04_quicksort
2017-12-01 16:33:44 -08:00
kde0820
cdec985db1 C quicksort (#44)
* Add C example for recursion

* Add loop_sum in c

* Add recursive_sum in c

* Add quicksort in c
2017-12-01 16:33:23 -08:00
Yossi Adler
ec2890a93d Add ES6 Examples to all chapters (#38)
* add ES6 example for binary search

* add ES6 example for selection sort

* add ES6 example for countdown

* add ES6 example for greet

* add ES6 example for factorial

* edit ES6 example for quicksort

* add ES6 example for loop sum

* add ES6 example for recursive sum

* add ES6 example for recursive count

* add ES6 example for recursive max

* add ES6 example for price of groceries

* add ES6 example for check voter

* add ES6 example for breadth-first search

* add ES6 example for dijkstras algorithm

* edit ES6 example for dijkstras algorithm

* edit ES6 example for set covering

* add ES6 example for longest common subsequence
2017-11-13 08:12:59 -08:00
chase-g
7d6d36ccb2 Adding Scala examples for Chapter 4 and Chapter 5 (#30)
* Add files via upload

* Update 01_countdown.scala

* Update 02_greet.scala

* Update 02_greet.scala

* Create scala

* Delete scala

* Add files via upload

* Add files via upload
2017-09-26 10:40:43 -07:00
Vladislav Khvostov
d76298722f Create quicksort.js 2017-09-26 10:40:15 -07:00