Commit Graph

272 Commits

Author SHA1 Message Date
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
Jinguang
f03841e79a Description:[fix] fixed the C++ compile error for std::find (#241)
Bug: NA
Test: 1.  add "#include <algorithm>" on fisrt line of the file
      2.  It could be normally compiler, or it will report compile error
2022-11-18 16:35:04 -06:00
Aditya Bhargava
07a6d6b506 fix broken case in binary search (python) and remove unneeded base cases 2022-11-18 16:33:23 -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
Udit Gupta
308148653a Enhances 'base case' logic (#227)
Original function does not work when input array is empty or contains a single value. In the revised code, base case has been augmented to support those. Works successfully for all these test cases: find_max([1, 12, 8, 5]), find_max([]), find_max([1])
2022-11-18 15:47:57 -06:00
Aditya Bhargava
3f02143f7f Expand contributions section in README 2022-11-18 15:35:44 -06:00
N3-M3-S1S
b3a143a3ae add dart examples for chapter 1 and 2 (#209)
* add dart example for chapter 1

* add dart example for chapter 2
2022-11-18 15:31:23 -06:00
spring monkey
cd38dc146d Fix formula (#206)
The current version of the formula incorrectly handles the factorial(0) and causes an infinite loop
2022-11-18 15:29:39 -06:00
Vasilii Boldurean
38f962f2a3 Fix: dijkstras example for JavaScript ES6. (#205) 2022-11-18 15:28:46 -06:00
Mikhail Bokov
c91f1ad37f Update 05_quicksort.php (#204) 2022-11-18 15:28:15 -06:00
Matvey
70d4d231bf Fix/Python 06 bfs: case when entrypoint is target (#203)
* Simplify cognitive complexity

* Fix case when entrypoint is target

* Simplyfy check for case: entrypoint is target
2022-11-18 15:27:29 -06:00
Sergey Ivanov
3868623fcd Update SelectionSort2.java (#184)
* Update SelectionSort2.java

Small method

* Update SelectionSort2.java
2022-11-18 14:58:46 -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
788c54e92b python lcs example needs to default to 0 if values dont match 2022-11-18 14:55:06 -06:00
Aditya Bhargava
35bb758f5e Delete 07_dijkstras_algorithm/golang directory
deleting to stop case insensitive issue on Mac
2022-11-18 14:53:39 -06:00
Pikachu
06a890c302 A pull request from cx (#164)
* The original code did not consider the exit condition when the stations cannot perfectly cover the states_needed.

* The code in 09_dynamic_programming/python/01_longest_common_subsequence.py is completed. And the 02_longest_common_substring.py is added.
2022-11-18 14:49:50 -06:00
Alexandr Shulaev
c029201ab1 Fixed formatting problems, example and JSDoc (#129) 2022-11-18 14:47:16 -06:00
Alexandr Shulaev
5f416d1129 Issues-126 - Fixed formatting, jsdoc and example for JavaScript/ES6 (#127)
* Issues-126 - Fixed formatting, jsdoc and non-working example for JavaScript/ES6

* Issues-126 - Fixed jsdoc
2022-11-18 14:46:18 -06:00
NikitaLipatov
64a09d6584 05 & 06 exercises (#114)
Co-authored-by: Aditya Bhargava <bluemangroupie@gmail.com>
2022-11-18 14:34:48 -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
TheDonrad
7d27d15c0d Create Module.bsl (#182) 2021-03-14 10:47:15 -05:00
AndriiNyzhnyk
85281425eb Add more examples for countdown (#183) 2021-03-14 10:46:00 -05:00
ZhanSwift
efa1c0d975 Update 01_selection_sort.swift (#187)
A new for loop statement
2021-03-14 10:44:12 -05:00
Eric Weiss
04823be518 return position (#188) 2021-03-14 10:43:52 -05: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
Kostarev Kirill
fec65db129 Few changes in Swift Code (#191)
* Replaced the confusing construction

* The algorithm works faster than the previous version
2021-03-14 10:42:14 -05:00
Dani El-Ayyass
c1c68d9d2a improve 01_breadth-first_search.py (#195) 2021-03-14 10:39:59 -05:00
Aditya Bhargava
893fd220a1 Merge pull request #196 from julish13/js-factorial-formula-adjustement
factorial formula adjustement
2021-03-14 10:39:17 -05:00
Aditya Bhargava
342a50ab6f Merge pull request #197 from ekram0/Ekram
add great common divisor function
2021-03-14 10:38:31 -05:00
Ekram Mohamed
9f330a765a add great common divisor function 2021-02-18 02:02:57 +02:00
Yulia Kolupaeva
0c4fdddb12 factorial formula adjustement
The formula in book is incorrect because it doesn't include the factorial(0) case and leads to infinite recursion in this case.
2021-02-16 18:10:32 +03:00
Aditya Bhargava
f1acf84f3a Merge pull request #176 from AndriiNyzhnyk/clear_rust_example
Rust. Clear not needed boilerplate.
2020-09-14 12:53:54 -05:00
Aditya Bhargava
de9146234d Merge pull request #174 from FoxyChmoxy/master
Python: Unit tests for Binary Search
2020-09-14 12:53:11 -05:00