Commit Graph

46 Commits

Author SHA1 Message Date
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
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
AndriiNyzhnyk
85281425eb Add more examples for countdown (#183) 2021-03-14 10:46:00 -05: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
a777aa6068 Merge pull request #167 from moogacs/master
add recursive soln. for python/03_recursion
2020-09-14 10:56:40 -05:00
Aditya Bhargava
1459b8928f Merge pull request #163 from lamalex/recursion-in-rust
Add rust examples to 03_recursion
2020-09-14 10:55:42 -05:00
Aditya Bhargava
0a64ea2802 Merge pull request #150 from neverovski/patch-1
Update zero factorial Golang
2020-09-14 10:49:40 -05:00
Alexandr Shulaev
34df0a6d08 Fixed formatting problems and JSDoc (#131)
* Fixed formatting problems and JSDoc

* Added returns for JSDoc
2020-09-14 10:46:30 -05:00
=
345d09b69e add recursive soln. 2020-06-03 15:28:01 +02:00
Alexander Launi
16a4ae12f6 Small syntax change in 03_factorial 2020-03-21 18:30:37 -04:00
Alexander Launi
24c91a4a0b Implement factorial using generic mathematics 2020-03-21 17:38:17 -04:00
Alexander Launi
2ff4f42d43 Implement countdown using generic mathematics 2020-03-21 16:43:51 -04:00
Alexander Launi
2aa26293b0 Add factorial examples in Rust 2020-03-21 16:20:51 -04:00
Alexander Launi
64e231a8c6 Add greet example in Rust 2020-03-21 16:16:22 -04:00
Alexander Launi
858e1e71e7 Add recursive countdown example in Rust 2020-03-21 16:08:56 -04:00
Dmitry Neverovski
b4c440089f Update zero factorial
The Definition of a Zero Factorial
Because zero has no lower numbers but is still in and of itself a number, there is still but one possible combination of how that data set can be arranged: it cannot. This still counts as one way of arranging it, so by definition, a zero factorial is equal to one, just as 1! is equal to one because there is only a single possible arrangement of this data set.
2019-11-20 20:15:19 +03: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
Michael Mkwelele
184f80127c Add tests for factorial example. (#112) 2019-11-12 09:18:52 -06: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
Maria Kovaleva
d7de908a82 Fix countdown.py returning None (#94)
The original code does not return the value in the if-clause and the return statement in the else-clause, which led to the function returning None at the end of the countdown (5, 4, 3, 2, 1, 0, None).
2018-12-28 08:25:48 -08:00
NikitaLipatov
8a0a191975 03 & 04 exercises (#96) 2018-12-28 08:25:01 -08:00
Timur Tarasenko
ac08df2ee7 Oralce PL/SQL examples of recursion (#91) 2018-10-18 08:27:58 -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
biosta
67291c451f Examples for Chapter 3 written in Perl 5 (#71)
* Create 01_countdown.pl

Recursion example #1 written in Perl 5

* Create 02_greet.pl

Recirsion example #2 written in Perl 5

* Create 03_factorial.pl

Recursion example #3 written in Perl 5
2018-04-29 08:27:14 -07:00
Evgeny Garlukovich
687d3fece6 Add Elixir examples for recursion 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
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
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
kde0820
b88af07fd0 Add C example for recursion (#41) 2017-11-13 08:11:41 -08:00
seong954t
38d50415e8 recursion_Golang (#33)
* recursion_Golang

* go_fmt
2017-10-15 13:31:56 -07:00
chase-g
44f8151e11 Adding Scala examples for Chapter 3 (#28)
* Add files via upload

* Update 01_countdown.scala

* Update 02_greet.scala

* Update 02_greet.scala
2017-09-25 17:29:03 -07:00
vendin
495a648a6a Adding PHP examples 2017-09-25 09:57:26 -07:00
zhangjiong
525ff6c314 Add Lua code for chapter 3 2017-08-27 14:25:58 -04:00
Aditya Bhargava
468fda77a2 clean up javascript files 2017-06-11 16:15:26 -07:00
Bijoy Thomas
6f78bdf3d7 Adding Haskell examples (#17)
* Adding binary search example for Haskell

* Adding selection sort example in Haskell

* Adding Haskell examples for chapter 3

* Adding examples for chapter 4

* Adding examples for chapter 5

* Adding git ignore

* Add Haskell example for BFS
2017-06-11 19:12:48 -04:00
Oleh Novikov
4631b7a156 add examples in java 8 (#12)
* code for chapters 3-9 in Java

* code for chapters 1 in Java

* code for chapter 2 in Java

* missing CheckVoter for chapter 5 in Java

* add missing sample output for SetCovering as a comment
2017-03-20 09:06:45 -07:00
Anthony Marchenko
12265a8c61 Add examples on Swift 3.0.2 (#11)
* 01_binary_search Swift 3.0.2

* 01_binary_search Swift 3.0.2

* add Chapter 2 - 01_selection_sort Swift 3.0.2 example

* 01_binary_search cosmetic note updates Swift 3.0.2

* 03_recursion Swift 3.0.2 examples

* 04_quicksort Swift 3.0.2 examples

* fix typo on quicksort example. Swift 3.0.2

* add  05_hash_tables examples on Swift 3.0.2

* add 01_breadth-first_search Swift 3.0.2 example

* 01_breadth-first_search fixing typo Swift 3.0.2

* add 01_dijkstras_algorithm on Swift 3.0.2

* add 08_greedy_algorithms Swift 3.0.2 example

* 01_longest_common_subsequence Swift 3.0.2 example
2017-03-15 16:05:38 -07:00
Jim Vaughan
62ed616954 add csharp examples (#10) 2016-11-07 13:43:30 -08:00
vdelacruzjardon
0aec97dbf2 Examples in Gambas (#5) by @vdelacruzjardon 2016-09-16 11:41:52 -07:00
Kevin Nguyen
df2775353a code from chapter 3 in javascript 2016-06-16 22:37:11 -07:00
Leon Rische
f6cb264c68 code for chapter 3 in ruby 2016-03-03 15:19:05 +01:00
Aditya Bhargava
8cf108a20c code for chapter 3 2016-03-02 14:15:37 -08:00