Commit graph

227 commits

Author SHA1 Message Date
pzpz
e41b0a3156
Fix the function for printing the queue (#1573)
Some checks failed
C / build (Release, clang, clang++, ubuntu-latest) (push) Failing after 17s
C / build (Release, gcc, g++, ubuntu-latest) (push) Failing after 13s
C / build (Release, cl, cl, windows-latest) (push) Has been cancelled
* renfined!

* Add toArray() function to array_queue.c and array_deque.c

---------

Co-authored-by: Xi-Row <astruggle123@putlook.com>
Co-authored-by: krahets <krahets@163.com>
2024-12-04 19:38:30 +08:00
Fleey
6a74972080
fix(lang: c, chapters: searching, sorting): Some serious errors (#1531)
Some checks failed
C / build (Release, clang, clang++, ubuntu-latest) (push) Failing after 31s
C / build (Release, gcc, g++, ubuntu-latest) (push) Failing after 12s
C / build (Release, cl, cl, windows-latest) (push) Has been cancelled
* fix: correct hash table insertion

* Use a pointer to a pointer instead of a single pointer in the insert function, ensuring proper updates to the hash table
* Bug fixes: This fixes issues with empty results.

* fix: correct issues in radix sort

* Replaced loop-based array copy with memcpy to ensure efficient memory copying in countingSortDigit
* Fixed a bug in radixSort where the maximum value search loop skipped the last element
* Bug fix: Ensures all elements are checked when determining the maximum value in the array

* perf: improve memory management by adding explicit memory release

* revert: Revert to using the old loop override array method and drop specific api's like memcpy.
2024-11-10 02:00:53 +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
rongyi
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 <krahets@163.com>
2024-05-18 18:19:19 +08:00
Lanjing Gong
0e221540a3
fix(c): Fix malloc allocation of secondary pointers can lead to dump issues (#1367) 2024-05-18 18:17:33 +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
nuquist19
2b11639103
fix(C): Update common.h (#1278)
请问这里为了防止重复包含头文件是不是应该改成COMMON_H,因为头文件名字叫做common.h
2024-04-15 14:54:28 +08:00
Yudong Jin
d484b08c15
Prepare 1.1.0 release (#1274)
* Update bucket_sort.c

* Fix the comments in quick_sort.c

* Update the announce badge

* Sync zh and zh-hant versions

* Update contributors list.

* Sync zh and zh-hant versions.

* Sync zh and zh-hant versions.

* Update the contributors list

* Update the version number
2024-04-14 20:46:20 +08:00
jiawenshi
16942dfe32
fix(C): fix the array initialization in coin_change.c (#1277)
* add

* Update coin_change.c

* Update coin_change.c

---------

Co-authored-by: Yudong Jin <krahets@163.com>
2024-04-14 17:30:21 +08:00
curtishd
4d9bbe72e1
Improve the consistency between code and comments in Kotlin (#1268)
* style(kotlin): Make code and comments consistent.

* style(kotlin): convert comment location.

* style(c): Add missing comment.

* style(kotlin): Remove redundant semicolon, parenthesis and brace

* style(kotlin): Put constants inside the function.

* style(kotlin): fix unnecessary indentation.

* style(swift): Add missing comment.

* style(kotlin): Add missing comment.

* style(kotlin): Remove redundant comment.

* style(kotlin): Add missing comment.

* Update linked_list.kt

* style(csharp,js,ts): Add missing comment.

* style(kotlin): Remove empty lines.

* Update list.cs

* Update list.js

* Update list.ts

* roll back to commit 1

* style(cs,js,ts): Add missing comment in docfile.

* style(kotlin): Use normal element swapping instead of scope functions.
2024-04-13 20:09:39 +08:00
Lanjing Gong
aca850244b
fix(C): fix array_hash_map.c and bucket_sort.c (#1272)
* fix: Fix coding error, https://github.com/krahets/hello-algo/discussions/440#discussioncomment-8958379

* fix: Fix issue 1237 https://github.com/krahets/hello-algo/issues/1237

* Update array_hash_map.c

* Update bucket_sort.c

* Update bucket_sort.c

* Update array_hash_map.c

* Update bucket_sort.c

* Update bucket_sort.c

---------

Co-authored-by: Yudong Jin <krahets@163.com>
2024-04-12 03:03:18 +08:00
Yang Le
db164f6703
fix memory leak in the C code (#1203)
* fix memory leak when size(deque) == 1

* fix memory leak
2024-04-07 01:36:55 +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
Yudong Jin
3ea91bda99
fix: Use int instead of float for the example code of log time complexity (#1164)
* Use int instead of float for the example code of log time complexity

* Bug fixes

* Bug fixes
2024-03-23 02:17:48 +08:00
Nan Lei
300a781fab
Update code comment of quadratic in time_complexity (#1155) 2024-03-19 02:28:16 +08:00
Yudong Jin
9769e14017
Fix the median_three mehod for quick sort (#1134)
* Add the section of terminologies.

* fix format

* Fix median_three function for quick sort

* Delete docs/chapter_appendix/terminologies.md

* Update quick_sort.ts

* Update quick_sort.rs

* Update quick_sort.js
2024-03-15 01:06:59 +08:00
Yudong Jin
01c67781fa
Bug fixes and improvements (#1133)
* Bug fixes

* Update the figure of the JD link

* Unify the code comments of insertion_sort
2024-03-14 20:01:16 +08:00
Arthur
962f8f91f7
fix some bugs in c codes (#1089) 2024-02-23 01:34:49 +08:00
Yudong Jin
a005c6ebd3
Some improvements (#1073)
* Update avatar's link in the landing page

* Bug fixes

* Move assets folder from overrides to docs

* Reduce figures' corner radius

* Update copyright

* Update header image

* Krahets -> krahets

* Update the landing page
2024-02-07 22:21:18 +08:00
gonglja
e69f60c07c
fix(linkedlist_queue.c): Remove redundant conditional judgments. (#1055) 2024-01-23 22:09:45 +08:00
Yudong Jin
f6976978dd
Prepare 1.0.0 release (#1044)
* Update the book with the thrid revised edition

* Fix a typo

* Update the contributors' information

* Update the mindmap

* Update the version number
2024-01-14 03:16:20 +08:00
Yudong Jin
ddd375af20
feat: Add visualizing code blocks based on the pythontutor (#1029)
* Update copyright

* Update the Python code

* Fix the code comments in ArrayBinaryTree

* Fix the code comments in ArrayBinaryTree

* Roll back time_comlexity.py

* Add the visualizing code(pythontutor) blocks to the chapter complexity, data structure, array and linked list, stack and queue, hash table, and backtracking

* Fix the code comments
2024-01-07 04:04:01 +08:00
gonglja
3a559f1b60
Fix some code bugs (#1021)
* fix(counting_sort.c): Fix access out-of-bounds issue

* fix(hash_map_open_addressing.c): Fix coding errors

* fix(binary_search_tree.c): Fix unreleased memory

* Update indentataion
2024-01-02 21:45:01 +08:00
codingonion
7ffef7e1d6
update the author info sjinzh -> codingonion (#1017)
* update author information

* Update index.md

---------

Co-authored-by: Yudong Jin <krahets@163.com>
2024-01-02 01:25:37 +08:00
Yudong Jin
f68bbb0d59
Update the book based on the revised second edition (#1014)
* Revised the book

* Update the book with the second revised edition

* Revise base on the manuscript of the first edition
2023-12-28 18:06:09 +08:00
Yudong Jin
6d961d38a0
Several improvements (#1002)
* Update buttons.

* Update button svg

* Update button

* Update README.md

* Update index.md

* Update translation of about_the _book

* Update English headings.
2023-12-24 10:37:25 +08:00
krahets
9a5ab776d6 A bug fix. 2023-12-19 21:55:57 +08:00
krahets
d9686e57dd Fix bubble_sort.c 2023-12-18 22:52:00 +08:00
gonglja
d67c458caa
fix(codes/c): Fix bubble_sort.c (#983) 2023-12-11 00:42:45 +08:00
Yudong Jin
e720aa2d24
feat: Revised the book (#978)
* Sync recent changes to the revised Word.

* Revised the preface chapter

* Revised the introduction chapter

* Revised the computation complexity chapter

* Revised the chapter data structure

* Revised the chapter array and linked list

* Revised the chapter stack and queue

* Revised the chapter hashing

* Revised the chapter tree

* Revised the chapter heap

* Revised the chapter graph

* Revised the chapter searching

* Reivised the sorting chapter

* Revised the divide and conquer chapter

* Revised the chapter backtacking

* Revised the DP chapter

* Revised the greedy chapter

* Revised the appendix chapter

* Revised the preface chapter doubly

* Revised the figures
2023-12-02 06:21:34 +08:00
Yudong Jin
b824d149cb
fix: Several code bug fixes (#973)
* Update counting_sort.c and quick_sort.c

* Code bug fixes.
2023-11-29 23:14:55 +08:00
gonglja
d960c99a1f
fix: bug fixes for array_hash_map.c and counting_sort.c (#968)
* fix(codes/cpp): Memory leak fix: the space was not freed when pop removed the element.

* fix(codes/cpp): Fix access error when printArray(arr, 0)

* Update PrintUtil.hpp

* fix(codes/c): Fix some errors of cmake build

* feat(codes/c): Add hashing_search.c

* styles(codes/c): Modify function description

* styles(codes/c): Modify binary_search.c code style

* fix(codes/c): Fix the problem in binary_tree_bfs.c and the problem that the memory is not released.

* feat: Add preorder_traversal_i_compact.c

* feat(codes/c): Add head_sort.c

* feat(codes/c): Add bucket_sort.c

* feat(codes/c): Add binary_search_edge.c

* fix(codes/c): Add programs that are not managed by cmake (c code)

* feat(codes/c): Add selection_sort.c

* style(codes/c): Change swap in selection_sort.c to `selectionSort`

* styles(codes/c): Change style.

* fix(codes/c): Fix some formatting errors and temporarily remove backtracking chapters

* fix(codes/c): Fix space_complexity.c build error.

* feat(codes/c): Add array_binary_tree.c

* feat(code/c): Update push_back and pop_back in vector.h

* styles(codes/c): Adjust  format.

* feat(codes/c): Add `interation.c ` `recursion.c` `simple_hash.c` `binary_search_edge.c` `binary_search_insertion.c` in C codes.

* fix(mylist.c): Fix `insert` function in `mylist.c`

https://github.com/krahets/hello-algo/discussions/32#discussioncomment-6974163

* feat(codes/c): Add binary_search_recur.c

* fix(codes/c): Bug fixes in discussion
https://github.com/krahets/hello-algo/discussions/78\#discussioncomment-7611511
https://github.com/krahets/hello-algo/discussions/428\#discussioncomment-7637613

---------

Co-authored-by: Yudong Jin <krahets@163.com>
2023-11-26 22:56:30 +08:00
Yudong Jin
f7c41b6bef
fix: Update C code for compatibility with the MSVC compiler (#949)
* Replace VLA with malloc
Replace VLA with malloc to make C code
compatible with cl compiler on Windows.

* Fix C code for CI compiler.

* Fix C code compability to CI.

* check the trigger
2023-11-17 00:29:54 +08:00
krahets
49745cf2d2 Add the link of math.h lib in CMakeList. 2023-11-16 21:14:20 +08:00
Yudong Jin
fcbaf101a4
Several bug fixes and improvements (#945)
* Update Dockerfile for code debugging.

* Format Python code using Black.

* Improve dark theme by defining html classes for the figures, animations and cover images.

* Fix several glossary translation.

* Update a code comment.

* Fix climbing_stairs_backtrack: the pruning should not require the sorted choices list.

* Update the code of array and list traversal.

* Fix a rendering issue of README.md

* Update code of list traversal.

* Fix array_definition.png

* Update README.md

* Fix max_capacity_moving_short_board.png

* Fix array.dart

* Fix array.dart

* Fix array.dart

* Fix array.dart
2023-11-14 21:27:35 +08:00
krahets
5f3ad1ed3d A few bug fixes. 2023-11-03 22:48:43 +08:00
krahets
355cc3a6b1 Bug fixes to C code. 2023-11-01 05:14:22 +08:00
Yudong Jin
9c28619839
feat: Reimplement the graph code for C (#901)
* Reimplement the graph code for C

* Free memory of **vertices.
2023-10-29 19:52:19 +08:00
krahets
db5d1d21f3 Several bug fixes. 2023-10-29 00:09:54 +08:00
lucas
f98b337144
refactor: Re-implement hanota.c (#885)
* feat: re-impl hanota.c

* chore: Remove useless comment code

* Update hanota.c

* Update hanota.c

* Update print_util.h

* Update CMakeLists.txt

---------

Co-authored-by: Yudong Jin <krahets@163.com>
2023-10-27 23:41:58 +08:00
Yudong Jin
492a69ebca
refactor: Replace vector with array in C code (#894)
* Re-implement merge sort function.

* Replace vector with array for C.

* fix
2023-10-27 23:26:48 +08:00
krahets
5385057993 Replace "结点" with "节点". 2023-10-27 23:24:13 +08:00
krahets
bd8cda325e A few improvements to the C code. 2023-10-27 01:13:36 +08:00
krahets
0e10274bb4 Update arrayToTree() and treeToArray() for C. 2023-10-27 01:04:17 +08:00
Yudong Jin
e441ee4e35
Re-implement merge sort function. (#888) 2023-10-26 02:56:33 +08:00
Yudong Jin
7822bf9cd4
feat: add top_k.c and refactor top_k.js (#889)
* Add top_k.c based on my_heap.c

* Improve the implementation of top_k.js

* Add a comment to top_k
2023-10-26 02:54:19 +08:00
Yudong Jin
d26e811e10
Several bug fixes and improvements. (#887)
* fix the bugs of C code.

* Add a header figure.

* Improve the definition of tree node height.
2023-10-25 22:59:25 +08:00
krahets
1e49574332 Simplify struct declarations of C.
Use PascalCase for all structs in C.
SImplify n_queens.c
Format C code for chapter of graph.
2023-10-18 02:16:26 +08:00
krahets
5392afd44b fix several bugs 2023-10-17 23:45:31 +08:00
Yudong Jin
51405c0669
add permutations_ii.c and re-implement permutations_i.c (#868) 2023-10-17 10:20:10 -05:00