44 Commits
Author SHA1 Message Date
Lukas a43c3fb6f6 Correct Ruby binary search, load factors and graph self-loop checks (#2001)
Co-authored-by: Lukas <[email protected]>
2026-11-24 01:26:48 +08:00
Yudong JinandClaude Opus 5.5 4fd605c502 Correct and unify doc snippets; fix errors in the demo sources (#2039)
Code snippets in the book are corrected and unified across languages and
kept as literal blocks in the snippet files. The demo sources keep their
#2033 form, with fixes only for real errors: wrong code, wrong printed
labels, comments that contradict the code, and typos. en/ja/ko demos are
rendered from the reviewed code dictionaries (krahets/hello-algo-workspace#78).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-23 15:29:13 +08:00
Yudong JinandClaude Opus 5.5 ded7ddc635 Revert the runnable-snippets batches to the #2033 state (#2038)
Reverts #2034, #2035, #2036 and #2037. The work will return in a single
reviewed PR that is completed before it merges. The tree equals 8c96e2f30
(#2033).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 06:45:32 +08:00
Yudong JinandClaude Opus 5.5 b113cb425a Cite the shared TreeNode for the AVL node and the C binary tree node (#2037)
Batch 3b of the runnable-snippets plan. avl_tree_node now cites each
language's shared TreeNode in all 13 languages, and the C tree_node_class
shares the same region. Rust gets an import region; Java, C#, Swift and
Kotlin skip their serialization helpers with an adjacent region.

The shared nodes gain reviewed field comments in C++ and Rust, aligned
comments in Java, Swift and Kotlin, and a spacing fix in JavaScript. The
AVL section adds one sentence saying the shared node class already has
height. Four ru Rust files whose multi-line statements had collapsed into
literal \n now compile again. en, ja, ko and zh-hant are regenerated; ru
is synced by hand.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 05:51:36 +08:00
Yudong JinandClaude Opus 5.5 bcd86fc1ed Cite demo-source regions for heap operations and the linked-list node classes (#2036)
Batch 3a of the runnable-snippets plan. heap_operations now cites the heap
demos in Python, C++, Java, C#, Go, Swift, Rust and Kotlin; the demos call
the library directly instead of push/pop helpers and print each popped value.
list_node_class cites each language's shared ListNode (Swift stays literal)
and doubly_list_node_class cites linkedlist_deque (Go stays literal).

Node comments adopt reviewed source wording, Rust and Swift get import
regions, the Ruby typo 前躯 becomes 前驱, and the TypeScript doubly node
fields become nullable. en, ja, ko and zh-hant are regenerated; ru is
synced by hand.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 05:23:41 +08:00
Yudong JinandClaude Opus 5.5 eeb8a3b790 Cite demo-source regions from the remaining A-class snippets (batch 2) (#2035)
Migrate init_array, hash_map_operations, hash_map_traversal,
queue_operations, deque_operations and insert_remove_node: zh and ru
demo sources gain region markers and the snippets' comments, en, ja and
ko are regenerated from reviewed translations, zh-hant via OpenCC. 70
blocks become region references; builtin_hash and five blocks without
reviewed translations stay literal.

The Java, Kotlin and Rust deque demos follow the book's order, and a few
demo comments and typos are aligned with the snippets.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 04:23:45 +08:00
Yudong JinandClaude Opus 5.5 849b6a95b9 Cite demo-source regions from doc snippets (pilot) (#2034)
Doc snippets for init_linked_list, init_binary_tree, stack_operations and
five list.md entries now reference marked regions of the demo programs
instead of copying code, so the book shows code that is compiled and run.

- Mark regions in the zh demo files and add the snippet comments that the
  demos lacked, reusing texts that already have reviewed translations.
- Sync ru by hand, regenerate en/ja/ko from the reviewed dictionaries and
  derive zh-hant with OpenCC.
- Convert 97 snippet blocks in six editions to [file]{..}-[region]{..}
  references; init_list and the Rust stack block stay literal until their
  comments have reviewed translations.

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-16 03:36:04 +08:00
Yudong JinandClaude Opus 5.5 083dfdc7bc Fix code block headers that pulled in the previous function (#2031)
When the header comment above a cited function did not match the extractor's
format, the extractor kept scanning upward and the book showed the end of the
previous function too. Fix those comments in all editions:

- ruby min_cost_climbing_stairs_dp.rb: `# ...` -> `### ... ###` (all editions);
- ruby unbounded_knapsack.rb: `### ... ##3` -> `### ... ###` (zh, ja, ko, ru);
- c top_k.c: `// ...` above topKHeap -> `/* ... */` (all editions);
- ru Ruby: restore the `###` prefix written as `# ##` on 25 lines in 12 files,
  following the Chinese original line by line.

Also normalize whitespace-only lines inside the code tabs of space_complexity.md
and suggestions.md (30 lines per edition) to empty lines; the built HTML of those
pages is unchanged. zh-hant is regenerated by OpenCC.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:48:52 +08:00
KingCrimsonJY 5b279d48b3 fix: handle single-node pops in linked-list deques (#1824) 2026-10-10 19:18:20 +08:00
Yudong Jin 28c1e74c1d Add multilingual exercise code (#1959)
Replace the exercise pages' Python-only snippets with source-backed implementations for the 13 visible programming languages, and localize reader-facing comments by site language. Zig remains out of scope.

Approval bypass: repository protection requires one approval but does not enforce it for administrators. All 68 completed checks succeeded; four non-required Java jobs remained queued on the existing ubuntu-20.04 workflow, with no failed checks.
2026-08-18 04:57:57 +08:00
Yudong Jin bf86c39b6c Fix multilingual content typos (#1958) 2026-08-18 03:08:23 +08:00
Yudong Jin e8dc4736a2 Bug fixes and improvements. (#1780)
* Fix the "尾递归优化" to "递归深度优化" in quick_sort.

* Update landing pages.

* Sync zh and zh-hant versions.

* Sync zh and zh-hant versions.
2025-07-10 06:32:25 +08:00
Flamingo 57cf6b1ea6 fix some typos (#1540) 2024-10-31 21:26:28 +08:00
Yudong Jin 3f4220de81 Bug fixes and improvements (#1380)
* preorder, inorder, postorder -> pre-order, in-order, post-order

* Bug fixes

* Bug fixes

* Update what_is_dsa.md

* Sync zh and zh-hant versions

* Sync zh and zh-hant versions.

* Update performance_evaluation.md and time_complexity.md

* Add @khoaxuantu to the landing page.

* Sync zh and zh-hant versions

* Add @ khoaxuantu to the landing page of zh-hant and en versions.
2024-05-31 16:39:06 +08:00
khoaxuantu a14be17b74 [feat] add ruby code - chapter dynamic programming (#1378) 2024-05-30 17:11:56 +08:00
khoaxuantu aa818945f0 feat: Add Ruby code - chapter "Backtracking" (#1373)
* [feat] add ruby code - chapter backtracking

* feat: add ruby code block - chapter backtracking
2024-05-24 15:41:40 +08:00
rongyiandYudong Jin 21be3fdaf8 [Rust] Normalize mid calculation in case overflow (#1363)
* Normalize mid calculate in case overflow

* Change ALL language

* Update merge_sort.py

* Update merge_sort.zig

* Update binary_search_tree.zig

* Update binary_search_recur.py

---------

Co-authored-by: Yudong Jin <[email protected]>
2024-05-18 18:19:19 +08:00
khoaxuantu 9e569cf520 feat: add ruby code - chapter "divide and conquer" (#1361) 2024-05-15 18:14:15 +08:00
khoaxuantu 1f606d6852 feat: add ruby codes - chapter greedy (#1350) 2024-05-08 18:38:35 +08:00
Yudong Jin c4a7966882 Bug fixes and improvements (#1348)
* Add "reference" for EN version. Bug fixes.

* Unify the figure reference as "the figure below" and "the figure above".
Bug fixes.

* Format the EN markdown files.

* Replace "" with <u></u> for EN version and bug fixes

* Fix biary_tree_dfs.png

* Fix biary_tree_dfs.png

* Fix zh-hant/biary_tree_dfs.png

* Fix heap_sort_step1.png

* Sync zh and zh-hant versions.

* Bug fixes

* Fix EN figures

* Bug fixes

* Fix the figure labels for EN version
2024-05-06 14:44:48 +08:00
khoaxuantuandYudong Jin cb32c525e7 feat: Add Ruby code - chapter "Sorting" (#1333)
* feat: add ruby code - chapter sorting

* Update radix_sort.rb

---------

Co-authored-by: Yudong Jin <[email protected]>
2024-05-03 19:46:42 +08:00
59d07264fc feat: add ruby code block - bucket sort (#1285)
* feat: add ruby code block - bucket sort

* Update codes/ruby/chapter_sorting/bucket_sort.rb

Co-authored-by: khoaxuantu <[email protected]>

* Update codes/ruby/chapter_sorting/bucket_sort.rb

Co-authored-by: khoaxuantu <[email protected]>

* Update bucket_sort.rb

---------

Co-authored-by: khoaxuantu <[email protected]>
Co-authored-by: Yudong Jin <[email protected]>
2024-04-30 16:00:39 +08:00
洪鈞閔 ( jasper )andkhoaxuantu 68f3a453e1 feat: add ruby code block - merge sort (#1260)
* feat(codes/ruby/chapter_sorting/merge_sort.rb): add merge_sort ruby file

* feat(codes/ruby/chapter_sorting/merge_sort.rb): modify comment space

* feat(codes/ruby/chapter_sorting/merge_sort.rb): set array default value

Co-authored-by: khoaxuantu <[email protected]>

* feat(codes/ruby/chapter_sorting/merge_sort.rb): driver code add if logic

Co-authored-by: khoaxuantu <[email protected]>

* feat(codes/ruby/chapter_sorting/merge_sort.rb): modify comment style

Co-authored-by: khoaxuantu <[email protected]>

* feat(codes/ruby/chapter_sorting/merge_sort.rb): modify logic instruction

Co-authored-by: khoaxuantu <[email protected]>

---------

Co-authored-by: khoaxuantu <[email protected]>
2024-04-30 15:58:47 +08:00
洪鈞閔 ( jasper )andkhoaxuantu 3f857db457 feat: add ruby code block - heap sort (#1261)
* feat(codes/ruby/chapter_sorting/heap_sort.rb): add heap_sort ruby file

* feat(codes/ruby/chapter_sorting/heap_sort.rb): modify comment space

* feat(codes/ruby/chapter_sorting/heap_sort.rb): modify code space style

* feat(codes/ruby/chapter_sorting/heap_sort.rb): modify logic instruction

Co-authored-by: khoaxuantu <[email protected]>

* feat(codes/ruby/chapter_sorting/heap_sort.rb): driver code add if logic

Co-authored-by: khoaxuantu <[email protected]>

---------

Co-authored-by: khoaxuantu <[email protected]>
2024-04-30 15:58:37 +08:00
a3950e1def feat: Add ruby codes - chapter "Heap" (#1300)
* init heap Ruby

* feature: finish chapter heap for ruby

* fix delete heap.rb

* fix: Fix code style

* Update codes/ruby/chapter_heap/my_heap.rb

Co-authored-by: khoaxuantu <[email protected]>

* Update codes/ruby/chapter_heap/top_k.rb

Co-authored-by: khoaxuantu <[email protected]>

* fix: apply the suggested changes

* fix to_a

* Update my_heap.rb

---------

Co-authored-by: khoaxuantu <[email protected]>
Co-authored-by: Yudong Jin <[email protected]>
2024-04-28 22:24:51 +08:00
Yudong Jin cfc273783b feat: Add glossary and description for "哈希集合" (#1310) 2024-04-28 22:00:25 +08:00
khoaxuantu 9e7fbf249f feat: add ruby code - chapter graph (#1303) 2024-04-26 17:30:55 +08:00
Yudong Jin f616dac7da Bug fixes and improvements (#1298)
* Fix is_empty() implementation in the stack and queue chapter

* Update en/CONTRIBUTING.md

* Remove "剩余" from the state definition of knapsack problem

* Sync zh and zh-hant versions

* Update the stylesheets of code tabs

* Fix quick_sort.rb

* Fix TS code

* Update chapter_paperbook

* Upload the manuscript of 0.1 section

* Fix binary_tree_dfs.rb

* Bug fixes

* Update README

* Update README

* Update README

* Update README.md

* Update README

* Sync zh and zh-hant versions

* Bug fixes
2024-04-22 02:26:32 +08:00
cy-by-side 499419e4ce Create quick_sort.rb (#1223)
* Create quick_sort.rb

* Update quick_sort.rb

* Update quick_sort.rb

* Update quick_sort.rb
2024-04-19 18:26:54 +08:00
khoaxuantu 19488b13c4 feat: add ruby codes - chapter tree (#1288) 2024-04-19 15:50:43 +08:00
khoaxuantu be9931c8a1 feat: Add Ruby code - chapter "Hashing" (#1276)
* feat: add ruby code - chapter hashing

* feat: add ruby code blocks - chapter hashing

* fix: comments
2024-04-15 16:20:26 +08:00
bluebean-cloud 92337671a6 feat: Add Ruby code - chapter "Searching" (#1262)
* create RUBY searching files & finish two_sum.rb

* finish linear_search.rb

* finish hashing_search.rb

* finish binary_search.rb

* finish binary_search_insertion.rb

* finish binary_search_edge.rb

* fix: change 'or' to '||'

* fix: Adjust the code style(ruby searching)

* fix: repair file name

* fix: Adjust the output format

* fix: fix 0...nums.length & delete useless require & change into __FILE__==0 block
2024-04-12 03:10:15 +08:00
cy-by-side 49e6a208f6 Create insertion_sort.rb (#1222)
* Create insertion_sort.rb

* Update insertion_sort.rb

* Update insertion_sort.rb

* Update insertion_sort.rb
2024-04-11 20:52:54 +08:00
khoaxuantu 6404a53fc6 chore: update driver code (#1265) 2024-04-10 22:38:48 +08:00
khoaxuantuandYudong Jin 41dd677338 Add Ruby test CI (#1242)
* test: add test all Ruby code

* test: add ruby test ci

* Update ruby.yml

---------

Co-authored-by: Yudong Jin <[email protected]>
2024-04-09 03:20:04 +08:00
khoaxuantu e121665772 feat: add ruby code - chapter stack and queue (#1230) 2024-04-07 14:48:48 +08:00
khoaxuantu 4fadad50ba fix: Some Ruby code (#1231)
* fix: ruby code block - chapter computational complexity

* fix: ruby code - chapter array and linkedlist
2024-04-07 01:39:45 +08:00
Yudong Jin 6e570e2863 Update README for zh-hant version (#1228)
* Bug fixes

* Fix the term in heap figures

* Unify the font of the chapter covers for the zh, en, and zh-Hant version

* Sync the zh-hant vertion with the main branch

* Update README for testing

* Update README for testing

* Update README for testing

* Update README for zh, en, zh-hant version

* Fix the issue links

* Update README

* Update README

* edition -> version
2024-04-06 03:57:46 +08:00
khoaxuantu 043085d0ea fix: adapt missing ruby style guide (#1216) 2024-04-03 21:01:29 +08:00
cy-by-sideandYudong Jin c435d177a1 Create chapter_computational_complexity/iteration.rb (#1207)
Co-authored-by: Yudong Jin <[email protected]>
2024-04-03 15:51:20 +08:00
khoaxuantu fd580a184a feat: Add Ruby code - chapter "computational complexity" (#1212)
* feat: add ruby code - chapter computational complexity

* feat: add ruby code blocks
2024-04-03 05:10:25 +08:00
khoaxuantu 5ce088de52 Fix inconsistent comments Ruby - chapter array and linked list (#1202)
* fix: inconsistent comments Ruby - chapter array and linked list

* fix: better Ruby code & comments
2024-03-31 15:58:35 +08:00
Yudong Jin 034ee65e9a Fix bugs and harmonize the code comments (#1199)
* Fix the comment in array_deque.go

* Fix the comment in bucket_sort.c

* Translate the Java code comments to Chinese

* Bug fixes

* 二分查找 -> 二分搜尋

* Harmonize comments in `utils` between multiple programming languages
2024-03-31 03:06:41 +08:00
khoaxuantu 85ca4cce43 feat: Add ruby code - chapter "array & linked list" (#1158)
* feat: add ruby code chapter array & linked list

- array.rb
- linked_list.rb
- list.rb
- my_list.rb

* feat: add ruby code blocks

* chore: fix convention
2024-03-30 13:10:46 +08:00