Commit graph

49 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
krahets
bd8cda325e A few improvements to the C code. 2023-10-27 01:13:36 +08:00
Yudong Jin
e441ee4e35
Re-implement merge sort function. (#888) 2023-10-26 02:56:33 +08:00
krahets
dd72335235 Format C, C++, C#, Go, Java, Python, Rust code. 2023-09-02 23:54:38 +08:00
krahets
2626de8d0b Polish the chapter
introduction, computational complexity.
2023-08-20 14:51:39 +08:00
gonglja
86209e0a7b
feat: Add C codes for bucket sort, heap sort, selection sort, binary search edge (#525)
* 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

---------

Co-authored-by: Yudong Jin <krahets@163.com>
2023-06-02 02:51:35 +08:00
krahets
eb8df49993 Update bubble sort and insertion sort. 2023-05-23 21:20:14 +08:00
krahets
f6d290d903 Update the comments of bubble sort
and insertion sort
2023-05-22 23:05:37 +08:00
krahets
78c84dfec6 Fix counting_sort.c 2023-05-03 22:58:48 +08:00
krahets
145975b335 Rename the common modules in Java, C++ and C. 2023-04-24 04:11:18 +08:00
Yudong Jin
dbc4906582
Publish the C codes to the docs. (#469) 2023-04-18 20:21:31 +08:00
krahets
af0f92c18d Fine tune the C codes. 2023-04-17 22:15:06 +08:00
krahets
9a98ff8a5e Format the C code in Clang-Format Style: Microsoft 2023-04-17 21:13:15 +08:00
krahets
0bec52d7cc Polish the chapter of heap, introduction, preface.
Replace "其它" with "其他"
2023-04-09 19:12:37 +08:00
Reanon
cac38c0c93
feat(bucket_sort): add bucket_sort code in go/c (#443)
* feat(bucket_sort): add bucket_sort code in go/c

* feat(go): add bucket_sort

* feat(c): add bucket_sort in c

* Update bucket_sort_test.go

---------

Co-authored-by: Yudong Jin <krahets@163.com>
2023-03-30 02:00:17 +08:00
Yudong Jin
34a1bca627
Add the section of radix sort. (#441) 2023-03-26 22:02:37 +08:00
Guanngxu
9b0bdd929f
feat: add C merge sort (#434)
* feat: add C merge sort

* Update merge_sort.c

---------

Co-authored-by: Yudong Jin <krahets@163.com>
2023-03-23 19:10:33 +08:00
Yudong Jin
65e47b0748
Add Python and C++ code for the counting sort. (#436) 2023-03-21 22:24:17 +08:00
Guanngxu
e539c44f63
feat: add C counting_sort (#430)
* feat: add C counting_sort

* Update CMakeLists.txt

---------

Co-authored-by: Yudong Jin <krahets@163.com>
2023-03-20 21:25:03 +08:00
Reanon
c837882dbd
feat(counting_sort): support counting_sort in c/go (#431)
* feat(go/counting_sort): support counting_sort in go

* feat(test): support counting_sort_naive testcase

* feat(go/counting_sort): support counting sort

* feat(c/counting_sort): support counting_sort in c
2023-03-20 21:16:25 +08:00
krahets
0840bc2043 Fix the deconstructor of linkedlist_queue.cpp 2023-03-16 18:43:13 +08:00
krahets
0b72fef381 Fix quick_sort.py 2023-02-21 21:51:56 +08:00
Leo.Cai
d249c8802e
add chapter_sorting by dart (#366)
* add chapter_sorting by dart

* fixed style of dart and bug mentioned before

* alter min value of dart

* Update radix_sort.dart

---------

Co-authored-by: Yudong Jin <krahets@163.com>
2023-02-19 01:03:42 +08:00
Reanon
da405b579d
Modify the code style of C (#299)
* style(my_list): modify c codes.

* style(stack): modify c codes.

* style(hash): modify c codes.
2023-01-29 00:08:12 +08:00
reanon
d4d11d9f7d fix(sort): add c codes 2023-01-18 14:20:42 +08:00
reanon
744a37925f feat(sort): add c codes 2023-01-18 14:15:27 +08:00
reanon
f72a1c6b3f feat(sort): add c codes 2023-01-18 14:14:57 +08:00
Yudong Jin
40b5be5302 Unify the naming of the C codes. 2023-01-12 00:31:11 +08:00
reanon
24cdcd54df feat(codes/c): add C include/ codes and modify exist C codes 2023-01-11 00:55:21 +08:00
Yudong Jin
0e49f0053a Update the format of the file headers
of c, cpp, java, js, ts, swift.
2023-01-06 03:39:19 +08:00
Yudong Jin
75217d5e8b Update bubble sort (C) and insertion sort (C). 2023-01-06 03:31:58 +08:00
L-Super
23bbaf12b9
Merge branch 'krahets:master' into patch-1 2022-12-30 09:30:51 +08:00
Listening
0dda12e0ab add insertion sort content 2022-12-30 09:26:26 +08:00
Yudong Jin
34ad07bfed Fine tune 2022-12-27 20:11:22 +08:00
Listening
edf1029ac4 fixed the format of the file header 2022-12-26 13:34:50 +08:00
Listening
2ee6fcfef1 add bubble sort in C code 2022-12-26 12:43:37 +08:00