C语言数据结构之平衡二叉树(BALANCED BINARY TREE)的简单实现

C语言数据结构之平衡二叉树(BALANCED BINARY TREE)的简单实现

平衡二叉树(BALANCED BINARY TREE),又名AVL树

  • 平衡二叉树的特点:
  • 左子树的值小于根的值,右子树的值大于根的值!!!
  • 左子树与右子树高度差的绝对值不大于1!!!
  • 大于1或小于-1表明树结构失去平衡,这个时候一定要进行再平衡操作,以保证树结构的平衡性!!!

首先实现一个基本框架

代码如下:

/* filename: avl.c */
#include <stdio.h>
#include <stdlib.h>/* compile : gcc avl.c -o avl                */
/*     run : ./avl                           */
/* memcheck: valgrind --leak-check=yes ./avl *//* function pointer with one arg for traversal */
typedef void (*ATFunc) (void *val);/* compare function pointer return int with two void* args */
typedef int  (*ATCmpFunc) (void *va, void *vb);/* the avltree datatype struct */
typedef struct _AvlTreeNode ATreeNode;
struct _AvlTreeNode {void *val;ATreeNode *lchild, *rchild;
};/* create a new avltree node */
ATreeNode *
avltree_node_new (void *val)
{ATreeNode *node = (ATreeNode*) malloc (sizeof(ATreeNode));node->val = val;node->lchild = NULL; node->rchild = NULL;return node;
}/* free avltree */
void
avltree_free (ATreeNode *root)
{if (root != NULL){avltree_free (root->lchild);avltree_free (root->rchild);free (root);}
}/* append a node,if val > root->val append to rightif val < root->val append to left,if val == root->val do not append, output info */
ATreeNode *
avltree_append (ATreeNode *root, void *val, ATCmpFunc cmpfunc)
{if (root == NULL){ATreeNode *node = avltree_node_new (val);return node;}if (0 > cmpfunc (val, root->val))root->lchild = avltree_append (root->lchild, val, cmpfunc);else if (0 < cmpfunc (val, root->val))root->rchild = avltree_append (root->rchild, val, cmpfunc);else{printf ("Info : Tree has same node [%p]\n", val);return root;}return root;
}/* inorder traversal help function */
static void
avltree_inorder_traversal_lrv (ATreeNode *root, ATFunc atfunc, int lv, char lr)
{if (root != NULL){avltree_inorder_traversal_lrv (root->lchild, atfunc, lv+1, 'L');for (int i = 0; i < lv; i++) printf ("  ");if (lr == 'L') printf ("<");if (lr == 'R') printf (">");atfunc (root->val);avltree_inorder_traversal_lrv (root->rchild, atfunc, lv+1, 'R');}else{for (int i = 0; i < lv; i++) printf ("  ");if (lr == 'L') printf ("<");if (lr == 'R') printf (">"); printf ("#\n");}
}/* inorder traversal */
void
avltree_inorder_traversal (ATreeNode *root, ATFunc atfunc)
{avltree_inorder_traversal_lrv (root, atfunc, 0, 'N');
}/* -------------------- *//* define function output long int datatype val */
static void
out_long (void *val)
{printf ("%ld\n", (long)val);
}/* define compare function compare long int datatype */
static int
cmp_long (void *a, void *b)
{long x = (long)(a), y = (long)(b);if (x > y) return 1;else if (x < y) return -1;return 0;
}/* test function */
void
test_avltree_append (void)
{ATreeNode *root = NULL;for (long i = 0; i < 10; i++)root = avltree_append (root, (void*)i, cmp_long);avltree_inorder_traversal (root, out_long);avltree_free (root);
}/**/
int
main (int argc, char *argv[])
{test_avltree_append ();return 0;
}
/* --(.|.)-- */

编译运行,效果如下:

songvm@ubuntu:~/works/xdn/too$ gcc avl.c -o avl
songvm@ubuntu:~/works/xdn/too$ ./avl<#
0<#>1<#>2<#>3<#>4<#>5<#>6<#>7<#>8<#>9>#
songvm@ubuntu:~/works/xdn/too$ 

从显示结果看,树结构变成链结构了,原因就是追加时未做调整!!!

  • 求树结构的高度 avltree_height
  • 树结构的平衡值 avltree_balance
  • 判断树结构是否平衡 avltree_is_balanced

在avltree_append函数前加入,代码如下:

/* return height of node root */
int
avltree_height (ATreeNode *root)
{int lh, rh;if (root == NULL) return 0;lh = avltree_height (root->lchild);rh = avltree_height (root->rchild);if (lh > rh)return lh + 1;elsereturn rh + 1;
}/* return balance value of node root */
int
avltree_balance (ATreeNode *root)
{int lh, rh;if (root == NULL) return 0;lh = avltree_height (root->lchild);rh = avltree_height (root->rchild);return lh - rh;
}/* if root is balanced return 1 else return 0 */
int
avltree_is_balanced (ATreeNode *root)
{int b = avltree_balance (root);if (b > 1 || b < -1) return 0;return 1;
}
  • 测试函数test_avltree_append

代码如下:

/* test function */
void
test_avltree_append (void)
{ATreeNode *root = NULL;for (long i = 0; i < 10; i++)root = avltree_append (root, (void*)i, cmp_long);//avltree_inorder_traversal (root, out_long);printf ("Tree height is %d\n", avltree_height (root));printf ("Tree balance is %d\n", avltree_balance (root));if (1 == avltree_is_balanced (root))printf ("Tree is balanced!\n");elseprintf ("Tree is not balanced!\n");avltree_free (root);
}

编译运行,达到预期,效果如下:

songvm@ubuntu:~/works/xdn/too$ gcc avl.c -o avl
songvm@ubuntu:~/works/xdn/too$ ./avl
Tree height is 10
Tree balance is -9
Tree is not balanced!
songvm@ubuntu:~/works/xdn/too$ 

当树在追加完节点后会出现不平衡的情况,这时可以通过旋转rotate操作来令其达到平衡

  • 左旋过程如下所示,右旋同理:
  0               1/ \             / \
#   1     ==>   0   2/ \         / \ / \#   2       #  # #  #/ \#   #
  • 当追加节点为右子节点的右子节点时,左旋!!!
  • 当追加节点为左子节点的左子节点时,右旋!!!
  • 左旋 avltree_left_rorate
  • 右旋 avltree_right_rorate

代码如下:

/* avltree node left rotate */
ATreeNode *
avltree_left_rotate (ATreeNode *root)
{ATreeNode *tmp = root->rchild;root->rchild = tmp->lchild;tmp->lchild = root;return tmp;
}/* avltree node right rotate */
ATreeNode *
avltree_right_rotate (ATreeNode *root)
{ATreeNode *tmp = root->lchild;root->lchild = tmp->rchild;tmp->rchild = root;return tmp;
}
  • 追加函数 avltree_append,在最后一行 return root; 前加入以下代码:
  int b = avltree_balance (root);if (b < -1 && val > root->rchild->val){root = avltree_left_rotate (root);}else if (b > 1 && val < root->lchild->val){root = avltree_right_rotate (root);}

测试函数

  • 测试左旋 test_avltree_append_lrotate
  • 测试右旋 test_avltree_append_rrotate
/* test left rotate function */
void
test_avltree_append_lrotate (void)
{ATreeNode *root = NULL;for (long i = 0; i < 7; i++)root = avltree_append (root, (void*)i, cmp_long);avltree_inorder_traversal (root, out_long);avltree_free (root);
}/* test right rotate function */
void
test_avltree_append_rrotate (void)
{ATreeNode *root = NULL;for (long i = 96; i >= 90; i--)root = avltree_append (root, (void*)i, cmp_long);avltree_inorder_traversal (root, out_long);avltree_free (root);
}

编译运行,测试左旋转函数,达到预期,效果如下:

songvm@ubuntu:~/works/xdn/too$ gcc avl.c -o avl
songvm@ubuntu:~/works/xdn/too$ ./avl<#<0>#<1<#>2>#
3<#<4>#>5<#>6>#
songvm@ubuntu:~/works/xdn/too$

编译运行,测试右旋转函数,达到预期,效果如下:

songvm@ubuntu:~/works/xdn/too$ gcc avl.c -o avl
songvm@ubuntu:~/works/xdn/too$ ./avl<#<90>#<91<#>92>#
93<#<94>#>95<#>96>#
songvm@ubuntu:~/works/xdn/too$ 

查看一下具体旋转过程

  • 将test_avltree_append_lrotate函数修改一下,每添加一个节点,查看一下树结构!

代码如下:

/* test left rotate function */
void
test_avltree_append_lrotate (void)
{ATreeNode *root = NULL;for (long i = 0; i < 7; i++){root = avltree_append (root, (void*)i, cmp_long);avltree_inorder_traversal (root, out_long);printf ("-------------------------\n");}avltree_free (root);
}

编译运行,基本看清了!!!效果如下:

songvm@ubuntu:~/works/xdn/too$ gcc avl.c -o avl
songvm@ubuntu:~/works/xdn/too$ ./avl<#
0>#
-------------------------<#
0<#>1>#
-------------------------<#<0>#
1<#>2>#
-------------------------<#<0>#
1<#>2<#>3>#
-------------------------<#<0>#
1<#<2>#>3<#>4>#
-------------------------<#<0>#<1<#>2>#
3<#>4<#>5>#
-------------------------<#<0>#<1<#>2>#
3<#<4>#>5<#>6>#
-------------------------
songvm@ubuntu:~/works/xdn/too$ 

另两种情况更复杂一些

  • 右左旋过程如下,左右旋同理:
   0               1/ \             / \#   2           0   2/ \   ==>   / \ / \1   #       #  # #  #/ \#   #
  • 当追加节点为右子节点的左子节点时,右左旋!!!
  • 当追加节点为左子节点的右子节点时,左右旋!!!
  • 左右旋 avltree_left_right_rotate
  • 右左旋 avltree_right_left_rotate

代码如下:

/* avltree node left right rotate */
ATreeNode *
avltree_left_right_rotate (ATreeNode *root)
{ATreeNode *tmp = root->lchild;root->lchild = avltree_left_rotate (tmp);return avltree_right_rotate (root);
}/* avltree node right left rotate */
ATreeNode *
avltree_right_left_rotate (ATreeNode *root)
{ATreeNode *tmp = root->rchild;root->rchild = avltree_right_rotate (tmp);return avltree_left_rotate (root);
}
  • 追加函数 avltree_append 的 return root; 前加上代码如下:
  else if (b > 1  && 0 < cmpfunc (val, root->lchild->val)){printf ("Left Right Rotate!\n");root = avltree_left_right_rotate (root);}else if (b < -1 && 0 > cmpfunc (val, root->rchild->val)){printf ("Right Left Rotate!\n");root = avltree_right_left_rotate (root);}

测试函数 test_avltree_append_rl_rotate

代码如下:

/* test left-right rotate and right-left rotate function */
void
test_avltree_append_rl_rotate (void)
{long arr[7] = {0, 2, 1, 4, 3, 6, 5};ATreeNode *root = NULL;for (long i = 0; i < 7; i++){root = avltree_append (root, (void*)(arr[i]), cmp_long);avltree_inorder_traversal (root, out_long);printf ("-------------------------\n");}avltree_free (root);
}

编译运行,效果如下,右左旋了三次,有点儿晕!!!

songvm@ubuntu:~/works/xdn/too$ gcc avl.c -o avl
songvm@ubuntu:~/works/xdn/too$ ./avl<#
0>#
-------------------------<#
0<#>2>#
-------------------------
Right Left Rotate!<#<0>#
1<#>2>#
-------------------------<#<0>#
1<#>2<#>4>#
-------------------------
Right Left Rotate!<#<0>#
1<#<2>#>3<#>4>#
-------------------------<#<0>#<1<#>2>#
3<#>4<#>6>#
-------------------------
Right Left Rotate!<#<0>#<1<#>2>#
3<#<4>#>5<#>6>#
-------------------------
songvm@ubuntu:~/works/xdn/too$ 

测试函数 test_avltree_append_lr_rotate

代码如下:

/* test left-right rotate function */
void
test_avltree_append_lr_rotate (void)
{long arr[7] = {6, 4, 5, 2, 3, 0, 1};ATreeNode *root = NULL;for (long i = 0; i < 7; i++){printf ("Append %ld\n", arr[i]);root = avltree_append (root, (void*)(arr[i]), cmp_long);avltree_inorder_traversal (root, out_long);printf ("-------------------------\n");}avltree_free (root);
}

编译运行,效果如下,这次看得清楚一些!!!

songvm@ubuntu:~/works/xdn/too$ gcc avl.c -o avl
songvm@ubuntu:~/works/xdn/too$ ./avl
Append 6<#
6>#
-------------------------
Append 4<#<4>#
6>#
-------------------------
Append 5
Left Right Rotate!<#<4>#
5<#>6>#
-------------------------
Append 2<#<2>#<4>#
5<#>6>#
-------------------------
Append 3
Left Right Rotate!<#<2>#<3<#>4>#
5<#>6>#
-------------------------
Append 0<#<0>#<2>#
3<#<4>#>5<#>6>#
-------------------------
Append 1
Left Right Rotate!<#<0>#<1<#>2>#
3<#<4>#>5<#>6>#
-------------------------
songvm@ubuntu:~/works/xdn/too$ 

按照值查找节点

  • 按照值查找节点函数 avltree_search

代码如下:

/* avltree search node by val call atcmpfunc if not found return NULL */
ATreeNode *
avltree_search (ATreeNode *root, void *val, ATCmpFunc atcmpfunc)
{int rc;ATreeNode *tmp = NULL;if (root == NULL) return tmp;rc = atcmpfunc (root->val, val);printf ("Info : Compare once!\n");if (0 == rc) return root;else if (1 == rc)tmp = avltree_search (root->lchild, val, atcmpfunc);elsetmp = avltree_search (root->rchild, val, atcmpfunc);return tmp;
}
  • 测试函数 test_avltree_search

代码如下:

/* test avltree search function */
void
test_avltree_search (void)
{long arr[15] = {14, 1, 3, 0, 4, 13, -2, 5, 6, 7, 8, 11, 9, 10, 12};ATreeNode *tmp, *root = NULL;for (long i = 0; i < 15; i++)root = avltree_append (root, (void*)(arr[i]), cmp_long);for (long i = 15; i < 31; i++)root = avltree_append (root, (void*)i, cmp_long);tmp = avltree_search (root, (void*)(15), cmp_long);printf ("Treenode val is %ld\n", (long)(tmp->val));tmp = avltree_search (root, (void*)(1), cmp_long);printf ("Treenode val is %ld\n", (long)(tmp->val));tmp = avltree_search (root, (void*)(30), cmp_long);printf ("Treenode val is %ld\n", (long)(tmp->val));tmp = avltree_search (root, (void*)(99), cmp_long);if (tmp == NULL)printf ("Value 99 not found in the tree!\n");elseprintf ("Treenode val is %ld\n", (long)(tmp->val));avltree_free (root);
}

编译运行,可以看到比较的次数!!!

songvm@ubuntu:~/works/xdn/too$ gcc -g avl.c -o avl
songvm@ubuntu:~/works/xdn/too$ ./avl
Info : Compare once!
Info : Compare once!
Treenode val is 15
Info : Compare once!
Info : Compare once!
Info : Compare once!
Treenode val is 1
Info : Compare once!
Info : Compare once!
Info : Compare once!
Info : Compare once!
Info : Compare once!
Info : Compare once!
Treenode val is 30
Info : Compare once!
Info : Compare once!
Info : Compare once!
Info : Compare once!
Info : Compare once!
Info : Compare once!
Value 99 not found in the tree!
songvm@ubuntu:~/works/xdn/too$ 

完整代码如下:

/* filename: avl.c */
#include <stdio.h>
#include <stdlib.h>/* compile : gcc avl.c -o avl                */
/*     run : ./avl                           */
/* memcheck: valgrind --leak-check=yes ./avl *//* function pointer with one arg for traversal */
typedef void (*ATFunc) (void *val);/* compare function pointer return int with two void* args */
typedef int  (*ATCmpFunc) (void *va, void *vb);/* the avltree datatype struct */
typedef struct _AvlTreeNode ATreeNode;
struct _AvlTreeNode {void *val;ATreeNode *lchild, *rchild;
};/* create a new avltree node */
ATreeNode *
avltree_node_new (void *val)
{ATreeNode *node = (ATreeNode*) malloc (sizeof(ATreeNode));node->val = val;node->lchild = NULL; node->rchild = NULL;return node;
}/* free avltree */
void
avltree_free (ATreeNode *root)
{if (root != NULL){avltree_free (root->lchild);avltree_free (root->rchild);free (root);}
}/* return height of node root */
int
avltree_height (ATreeNode *root)
{int lh, rh;if (root == NULL) return 0;lh = avltree_height (root->lchild);rh = avltree_height (root->rchild);if (lh > rh)return lh + 1;elsereturn rh + 1;
}/* return balance value of node root */
int
avltree_balance (ATreeNode *root)
{int lh, rh;if (root == NULL) return 0;lh = avltree_height (root->lchild);rh = avltree_height (root->rchild);return lh - rh;
}/* if root is balanced return 1 else return 0 */
int
avltree_is_balanced (ATreeNode *root)
{int b = avltree_balance (root);if (b > 1 || b < -1) return 0;return 1;
}/* avltree node left rotate */
ATreeNode *
avltree_left_rotate (ATreeNode *root)
{ATreeNode *tmp = root->rchild;root->rchild = tmp->lchild;tmp->lchild = root;return tmp;
}/* avltree node right rotate */
ATreeNode *
avltree_right_rotate (ATreeNode *root)
{ATreeNode *tmp = root->lchild;root->lchild = tmp->rchild;tmp->rchild = root;return tmp;
}/* avltree node left right rotate */
ATreeNode *
avltree_left_right_rotate (ATreeNode *root)
{ATreeNode *tmp = root->lchild;root->lchild = avltree_left_rotate (tmp);return avltree_right_rotate (root);
}/* avltree node right left rotate */
ATreeNode *
avltree_right_left_rotate (ATreeNode *root)
{ATreeNode *tmp = root->rchild;root->rchild = avltree_right_rotate (tmp);return avltree_left_rotate (root);
}/* append a node,if val > root->val append to rightif val < root->val append to left,if val == root->val do not append, output info */
ATreeNode *
avltree_append (ATreeNode *root, void *val, ATCmpFunc cmpfunc)
{if (root == NULL){ATreeNode *node = avltree_node_new (val);return node;}if (0 > cmpfunc (val, root->val))root->lchild = avltree_append (root->lchild, val, cmpfunc);else if (0 < cmpfunc (val, root->val))root->rchild = avltree_append (root->rchild, val, cmpfunc);else{printf ("Info : Tree has same node [%p]\n", val);return root;}int b = avltree_balance (root);if (b < -1 && val > root->rchild->val){root = avltree_left_rotate (root);}else if (b > 1 && val < root->lchild->val){root = avltree_right_rotate (root);}else if (b > 1  && 0 < cmpfunc (val, root->lchild->val)){printf ("Left Right Rotate!\n");root = avltree_left_right_rotate (root);}else if (b < -1 && 0 > cmpfunc (val, root->rchild->val)){printf ("Right Left Rotate!\n");root = avltree_right_left_rotate (root);}return root;
}/* avltree search node by val call atcmpfunc if not found return NULL */
ATreeNode *
avltree_search (ATreeNode *root, void *val, ATCmpFunc atcmpfunc)
{int rc;ATreeNode *tmp = NULL;if (root == NULL) return tmp;rc = atcmpfunc (root->val, val);printf ("Info : Compare once!\n");if (0 == rc) return root;else if (1 == rc)tmp = avltree_search (root->lchild, val, atcmpfunc);elsetmp = avltree_search (root->rchild, val, atcmpfunc);return tmp;
}/* inorder traversal help function */
static void
avltree_inorder_traversal_lrv (ATreeNode *root, ATFunc atfunc, int lv, char lr)
{if (root != NULL){avltree_inorder_traversal_lrv (root->lchild, atfunc, lv+1, 'L');for (int i = 0; i < lv; i++) printf ("  ");if (lr == 'L') printf ("<");if (lr == 'R') printf (">");atfunc (root->val);avltree_inorder_traversal_lrv (root->rchild, atfunc, lv+1, 'R');}else{for (int i = 0; i < lv; i++) printf ("  ");if (lr == 'L') printf ("<");if (lr == 'R') printf (">"); printf ("#\n");}
}/* inorder traversal */
void
avltree_inorder_traversal (ATreeNode *root, ATFunc atfunc)
{avltree_inorder_traversal_lrv (root, atfunc, 0, 'N');
}/* -------------------- *//* define function output long int datatype val */
static void
out_long (void *val)
{printf ("%ld\n", (long)val);
}/* define compare function compare long int datatype */
static int
cmp_long (void *a, void *b)
{long x = (long)(a), y = (long)(b);if (x > y) return 1;else if (x < y) return -1;return 0;
}/* test function */
void
test_avltree_append (void)
{ATreeNode *root = NULL;for (long i = 0; i < 10; i++)root = avltree_append (root, (void*)i, cmp_long);//avltree_inorder_traversal (root, out_long);printf ("Tree height is %d\n", avltree_height (root));printf ("Tree balance is %d\n", avltree_balance (root));if (1 == avltree_is_balanced (root))printf ("Tree is balanced!\n");elseprintf ("Tree is not balanced!\n");avltree_free (root);
}/* test left rotate function */
void
test_avltree_append_lrotate (void)
{ATreeNode *root = NULL;for (long i = 0; i < 7; i++){root = avltree_append (root, (void*)i, cmp_long);avltree_inorder_traversal (root, out_long);printf ("-------------------------\n");}avltree_free (root);
}/* test right rotate function */
void
test_avltree_append_rrotate (void)
{ATreeNode *root = NULL;for (long i = 96; i >= 90; i--)root = avltree_append (root, (void*)i, cmp_long);avltree_inorder_traversal (root, out_long);avltree_free (root);
}/* test right-left rotate function */
void
test_avltree_append_rl_rotate (void)
{long arr[7] = {0, 2, 1, 4, 3, 6, 5};ATreeNode *root = NULL;for (long i = 0; i < 7; i++){root = avltree_append (root, (void*)(arr[i]), cmp_long);avltree_inorder_traversal (root, out_long);printf ("-------------------------\n");}avltree_free (root);
}/* test left-right rotate function */
void
test_avltree_append_lr_rotate (void)
{long arr[7] = {6, 4, 5, 2, 3, 0, 1};ATreeNode *root = NULL;for (long i = 0; i < 7; i++){printf ("Append %ld\n", arr[i]);root = avltree_append (root, (void*)(arr[i]), cmp_long);avltree_inorder_traversal (root, out_long);printf ("-------------------------\n");}avltree_free (root);
}/* test avltree search function */
void
test_avltree_search (void)
{long arr[15] = {14, 1, 3, 0, 4, 13, -2, 5, 6, 7, 8, 11, 9, 10, 12};ATreeNode *tmp, *root = NULL;for (long i = 0; i < 15; i++)root = avltree_append (root, (void*)(arr[i]), cmp_long);for (long i = 15; i < 31; i++)root = avltree_append (root, (void*)i, cmp_long);tmp = avltree_search (root, (void*)(15), cmp_long);printf ("Treenode val is %ld\n", (long)(tmp->val));tmp = avltree_search (root, (void*)(1), cmp_long);printf ("Treenode val is %ld\n", (long)(tmp->val));tmp = avltree_search (root, (void*)(30), cmp_long);printf ("Treenode val is %ld\n", (long)(tmp->val));tmp = avltree_search (root, (void*)(99), cmp_long);if (tmp == NULL)printf ("Value 99 not found in the tree!\n");elseprintf ("Treenode val is %ld\n", (long)(tmp->val));avltree_free (root);
}/**/
int
main (int argc, char *argv[])
{//test_avltree_append ();//test_avltree_append_lrotate ();//test_avltree_append_rrotate ();//test_avltree_append_rl_rotate ();//test_avltree_append_lr_rotate ();test_avltree_search ();return 0;
}
/* --(.|.)-- */
  • 平衡二叉树删除节点的方法与普通二叉树的删除节点的方法稍有区别,因为要保证树的平衡!!!
  • 下一步研究一下!!!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.xdnf.cn/news/2948.html

如若内容造成侵权/违法违规/事实不符,请联系一条长河网进行投诉反馈,一经查实,立即删除!

相关文章

CentOS 文件系统扩容与缩容

一、 概述 理解Linux文件系统的管理&#xff0c;需要了解以下的一张图&#xff1a; 一般使用LVM (Logical Volume Manager) 管理磁盘存储&#xff0c;该工具允许用户更灵活地分配和管理存储空间。主要有以下几个概念&#xff1a; PV&#xff08;Physical Volume&#xff0c;物…

Linux系统使用第三方邮件客户端发送邮件

文章目录 安装第三方邮件客户端&#xff08;s-nail&#xff09;S-nail的简单介绍重要的特性差异 配置邮件服务配置文件 (以QQ邮箱为例)获取QQ邮箱授权码获取QQ服务器证书使用 OpenSSL 获取 QQ 邮箱服务器的证书安装OpenSSL连接到 QQ 邮箱的 SMTP 服务器并下载证书保存证书验证证…

家常菜点餐|基于java和小程序的家庭大厨家常菜点餐系统设计与实现(源码+数据库+文档)

家常菜点餐系统 目录 基于java和小程序的家庭大厨家常菜系统设计与实现 一、前言 二、系统设计 三、系统功能设计 四、数据库设计 五、核心代码 六、论文参考 七、最新计算机毕设选题推荐 八、源码获取&#xff1a; 博主介绍&#xff1a;✌️大厂码农|毕设布道师&am…

利士策分享,青年暴富难守,因何在?

利士策分享&#xff0c;青年暴富难守&#xff0c;因何在? 在人生的长河中&#xff0c;有些人似乎被命运特别眷顾&#xff0c;在年轻之时便轻易地获得了财富。 然而&#xff0c;令人遗憾的是&#xff0c;这些早年得志、财富易得的人&#xff0c;往往难以长久地守住这份来之不…

Echarts环形图引线设置

直接上图吧 直接上代码吧 let labelArr [直接访问, 邮件营销, 联盟广告, 视频广告, 搜索引擎]; let valueArr [{ value: 335, name: 直接访问 },{ value: 310, name: 邮件营销 },{ value: 234, name: 联盟广告 },{ value: 135, name: 视频广告 },{ value: 154, name: 搜索引…

Java8->Java19的初步探索

导读 最近网上开始了大量的关于Java19的讨论&#xff0c;我也想着用了Java8这么久该接受一点新的东西了&#xff0c;于是便开始研究了起来 Java 19 Java19是一个免费版本。下面是JDK19的支持图 image.png &#xff08;来源&#xff1a; https://www.bilibili.com/video/BV1V84…

软件设计师-上午题-15 计算机网络(5分)

计算机网络题号一般为66-70题&#xff0c;分值一般为5分。 目录 1 网络设备 1.1 真题 2 协议簇 2.1 真题 3 TCP和UDP 3.1 真题 4 SMTP和POP3 4.1 真题 5 ARP 5.1 真题 6 DHCP 6.1 真题 7 URL 7.1 真题 8 浏览器 8.1 真题 9 IP地址和子网掩码 9.1 真题 10 I…

nodejs批量修改word文档目录样式

工作中遇到一个需求:写个nodejs脚本,对word文档(1000+个)的目录页面进行美化。实现过程遇到不少麻烦,在此分享下。 整体思路 众所周知,Docx格式的Word文档其实是个以xml文件为主的zip压缩包,所以,页面美化整体思路是:先将文档后缀名改为zip并解压到本地,然后将关键的…

MathType在Word中的安装与配置记录

一、记录过程 1.MathType安装包下载 可直接下载本人已经安装过的安装包&#xff0c;亲测可以使用&#xff0c;下载链接如下&#xff1a; 链接&#xff1a;https://pan.baidu.com/s/1g-iOgKIqzSNz0E5rEUryug 提取码&#xff1a;1kb3 2.安装后配置 word中会出现mathtype的选项…

无人机之中继通信技术篇

一、定义与原理 无人机中继通信技术是指通过无人机搭载中继设备&#xff0c;将信号从一个地点传输到另一个地点&#xff0c;从而延长通信距离并保持较好的通信质量。其原理类似于传统的中继通信&#xff0c;即在两个终端站之间设置若干中继站&#xff0c;中继站将前站送来的信号…

轴流风机和后倾式风机的安装要求

后向离心风机风压大&#xff0c;风量足&#xff0c;安装方便。因为不需要蜗壳&#xff0c;所以风道往往需要自行设计&#xff0c;而风道的合理与否&#xff0c;大大影响了后向离心风机的效率。那么后向离心风机的安装技巧有哪些&#xff1f;怎样达到风机的最佳使用效果呢&#…

植物神经紊乱不用怕,这些维生素来帮你!

你是否经常感到身体疲惫、情绪波动大、心悸、胸闷&#xff1f;这可能是植物神经紊乱在作祟。别担心&#xff0c;通过合理的维生素补充&#xff0c;可以有效缓解症状&#xff0c;提升生活质量。今天&#xff0c;我们就来聊聊植物神经紊乱患者应该补充哪些维生素。 &#x1f50d…

使用C语言进行信号处理:从理论到实践的全面指南

1. 引言 在现代操作系统中&#xff0c;信号是一种进程间通信机制&#xff0c;它允许操作系统或其他进程向一个进程发送消息。信号可以用来通知进程发生了一些重要事件&#xff0c;如用户请求终止进程、硬件异常、定时器超时等。掌握信号处理技术对于开发健壮、高效的系统程序至…

LabVIEW配电产品精度测试系统

开发了一种基于LabVIEW平台的配电产品精度测试系统&#xff0c;通过自动化测试流程实现更高的测试准确性与效率。系统采用串口和TCP通信技术&#xff0c;与多功能交流采样变送器和配电设备无缝数据交互&#xff0c;提升了测试工作的可靠性和一致性。 一、项目背景 在配电产品…

基于JAVA SpringBoot和Vue社区网格化管理服务平台设计

摘要 本文旨在设计并实现一个基于Java SpringBoot和Vue技术的社区网格化管理服务平台。该平台主要包括用户功能和管理员功能两大部分&#xff0c;用户功能涵盖单位管理、问卷调查、论坛讨论、公告查看等&#xff1b;管理员功能则包括单位管理、基础数据维护、帖子和公告类型管…

鸢尾博客项目开源

1.博客介绍 鸢尾博客是一个基于Spring BootVue3 TypeScript ViteJavaFx的客户端和服务器端的博客系统。项目采用前端与后端分离&#xff0c;支持移动端自适应&#xff0c;配有完备的前台和后台管理功能。后端使用Sa-Token进行权限管理,支持动态菜单权限&#xff0c;服务健康…

IBinder源码分析

基础概念 binder 是 Android 中主要的跨进程通信方式&#xff0c;binder 驱动和 service manager 分别相当于网络协议中的路由器和 DNS&#xff0c;并基于 mmap 实现了 IPC 传输数据时只需一次拷贝。binder 包括 BinderProxy、BpBinder 等各种 Binder 实体&#xff0c;以及对 …

PDF Reader Pro for mac激活版 PDF编辑阅读器

PDF Reader Pro阅读器是一款用户必备的集管理、编辑、转换、阅读功能于一体的专业的全能PDF阅读专家。快速、易用、强大&#xff0c;让您出色完成 PDF 工作&#xff0c;深受全球9000万用户的喜爱。用户可轻松使用PDF Reader Pro进行文档阅读、编辑、注释、填写Form表单、转换、…

图像分割从基础到进阶:阈值化、K-means和Mean-Shift算法的应用

图像分割是计算机视觉中的一项关键技术&#xff0c;用来将图像划分为若干个 有意义 的区域&#xff0c;以便后续的图像处理和分析工作。根据任务的不同&#xff0c;图像分割可以进一步细分为语义分割、实例分割和全景分割&#xff1a; 语义分割 (Semantic Segmentation) 对图像…

生产消费者模型

线程同步 互斥锁(互斥量)条件变量生产/消费者模型 一、互斥锁 C11提供了四种互斥锁&#xff1a; mutex&#xff1a;互斥锁。timed_mutex&#xff1a;带超时机制的互斥锁。recursive_mutex&#xff1a;递归互斥锁。recursive_timed_mutex&#xff1a;带超时机制的递归互斥锁…