mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-17 11:32:10 +08:00
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
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Print an Array */
|
||||
/* 打印数组 */
|
||||
void printArray(int arr[], int size) {
|
||||
if (arr == NULL || size == 0) {
|
||||
printf("[]");
|
||||
@@ -31,7 +31,7 @@ void printArray(int arr[], int size) {
|
||||
printf("%d]\n", arr[size - 1]);
|
||||
}
|
||||
|
||||
/* Print an Array */
|
||||
/* 打印数组 */
|
||||
void printArrayFloat(float arr[], int size) {
|
||||
if (arr == NULL || size == 0) {
|
||||
printf("[]");
|
||||
@@ -44,7 +44,7 @@ void printArrayFloat(float arr[], int size) {
|
||||
printf("%.2f]\n", arr[size - 1]);
|
||||
}
|
||||
|
||||
/* Print a linked list */
|
||||
/* 打印链表 */
|
||||
void printLinkedList(ListNode *node) {
|
||||
if (node == NULL) {
|
||||
return;
|
||||
@@ -69,7 +69,6 @@ Trunk *newTrunk(Trunk *prev, char *str) {
|
||||
return trunk;
|
||||
}
|
||||
|
||||
/* Helper function to print branches of the binary tree */
|
||||
void showTrunks(Trunk *trunk) {
|
||||
if (trunk == NULL) {
|
||||
return;
|
||||
@@ -78,7 +77,11 @@ void showTrunks(Trunk *trunk) {
|
||||
printf("%s", trunk->str);
|
||||
}
|
||||
|
||||
/* Help to print a binary tree, hide more details */
|
||||
/**
|
||||
* 打印二叉树
|
||||
* This tree printer is borrowed from TECHIE DELIGHT
|
||||
* https://www.techiedelight.com/c-program-print-binary-tree/
|
||||
*/
|
||||
void printTreeHelper(TreeNode *node, Trunk *prev, bool isRight) {
|
||||
if (node == NULL) {
|
||||
return;
|
||||
@@ -106,12 +109,12 @@ void printTreeHelper(TreeNode *node, Trunk *prev, bool isRight) {
|
||||
printTreeHelper(node->left, trunk, false);
|
||||
}
|
||||
|
||||
/* Print a binary tree */
|
||||
/* 打印二叉树 */
|
||||
void printTree(TreeNode *root) {
|
||||
printTreeHelper(root, NULL, false);
|
||||
}
|
||||
|
||||
/* Print a Heap */
|
||||
/* 打印堆 */
|
||||
void printHeap(int arr[], int size) {
|
||||
TreeNode *root;
|
||||
printf("堆的数组表示:");
|
||||
|
||||
Reference in New Issue
Block a user