Commit Graph

24 Commits

Author SHA1 Message Date
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
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
Aditya Bhargava
d001cbd41e Merge pull request #156 from OlexanderD/patch-5
Changed code style according to new Java versions
2020-09-14 10:53:35 -05:00
Aditya Bhargava
77a3f8fcc7 Merge pull request #141 from Alexandrshy/issues-140-formatting-problems-and-example-for-greedy-algorithms
Fixed formatting problems
2020-09-14 10:48:25 -05:00
Alexander Danilchenko
52a5a7cc24 Changed code style according to new Java versions
Changed long and ugly type declarations with "var" keyword (Java 10).  Also fixed warning about raw usage of HashSet without type specification.
2020-01-12 18:34:55 +02:00
Lu Zhang
878e26217d Update SetCovering.java (#120)
The statesNeeded and finalStations set should be updated after the for loop which finds the bestStation.
2019-10-30 16:32:32 -05:00
Alexander Danilchenko
03db2855d6 According to the book changes (#144)
Changed the name of the variable according to the book
2019-10-30 16:31:21 -05:00
Alexander Danilchenko
fb81c11ca9 C++11 solution to the 8th chapter problem. (#145)
* C++11 solution to 8th chapter problem.

* Update 01_set_covering.cpp

* Extra space correction
2019-10-30 16:30:40 -05:00
Ivan Novikov
009689b294 Kotlin examples for 08 chapter (#147) 2019-10-30 16:30:20 -05:00
Alexandrshy
5a1d2c04d4 Fixed formatting problems 2019-07-26 00:29:41 +04: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
Yuriy Marad
2bf2ab5062 Add PHP example based on DS extension for chapter 08 - greedy algorithms (#97)
* Add PHP example based on DS extension for chapter 08 - greedy algorithms

* Add code formatting

* Add code formatting / 2
2018-12-28 08:24:40 -08:00
Evgeny Garlukovich
51c5cfb058 Add Elixir example for greedy algorithms 2018-04-20 08:18:52 -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
Seoungtae Kim
5703ee1e7a golang about 08_greedy_algorithms (#47)
* 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

* 08_greedy_algorithms for golang
2018-01-04 06:47:13 -08:00
Bijoy Thomas
542f4ab0a0 Added Haskell example for Dijkstras algorithm (#18)
* 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

* resetting

* Adding haskell example for dijkstras algorithm

* Adding Haskell example for chapter 8

* Adding power set based solution for set covering problem

* Adding Haskell examples for chap 9
2017-11-13 08:16:12 -08:00
zhangjiongwx
d0ac45bcde Add Lua code for chapter 6-9 (#36)
* Add Lua code for chapter 6

* Add Lua code for chapter 7

* Add Lua code for chapter 8

* Add Lua code for chapter 9
2017-11-13 08:14:24 -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
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
Kevin Nguyen
4a98a14bc1 code for chapter 8 in javascript 2016-06-21 21:52:26 -07:00
Leon Rische
58b026e7b8 code for chapter 8 in ruby 2016-03-03 16:15:47 +01:00
Aditya Bhargava
26aa694fbc code for chapter 8 2016-03-02 15:05:49 -08:00