mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-10 06:26:08 +00:00
Fine tune the C codes.
This commit is contained in:
@@ -20,6 +20,7 @@ avlTree *newAVLTree() {
|
||||
return tree;
|
||||
}
|
||||
|
||||
/* 获取节点高度 */
|
||||
int height(TreeNode *node) {
|
||||
// 空节点高度为 -1 ,叶节点高度为 0
|
||||
if (node != NULL) {
|
||||
@@ -247,4 +248,6 @@ int main() {
|
||||
/* 查询节点 */
|
||||
TreeNode *node = search(tree, 7);
|
||||
printf("\n查找到的节点对象节点值 = %d \n", node->val);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ struct binarySearchTree {
|
||||
|
||||
typedef struct binarySearchTree binarySearchTree;
|
||||
|
||||
/* 比较器:从小到大排序 */
|
||||
int sortIntHelper(const void *a, const void *b) {
|
||||
// 从小到大排序
|
||||
return (*(int *)a - *(int *)b);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user