堆与二叉树(下)

接着上次的,这里主要介绍的是堆排序,二叉树的遍历,以及之前讲题时答应过的简单二叉树问题求解


堆排序

给一组数据,升序(降序)排列

思路

思考:如果排列升序,我们应该建什么堆?

首先,如果排升序,数列最后一个数是 最大数,我们的思路是通过 向上调整 或者 向下调整,数组存放的第一个数不是最小值(小堆)就是最大值(大堆),此时我们将最后一个数与第一个数交换,使得最大值放在最后,此时再使用向上调整 或者 向下调整,得到第二大的数,重复上述动作,很明显,我们需要的第一个数是最大值,因此我们需要建大堆

反之,排降序,建立小堆


代码

#include<stdio.h>
void downAdjust(int* pa, int parent, int n)
{
	int child = parent * 2 + 1;
	while (child < n)
	{
		if (child + 1 < n && pa[child] > pa[child + 1])
		{
			child++;
		}
		if (pa[parent] > pa[child])
		{
			swap(&pa[parent], &pa[child]);
		}
		else
		{
			break;
		}
		parent = child;
		child = parent * 2 + 1;
	}
}
int main()
{
	int arr[] = { 1,3,2,5,7,4,7,4,2,5,6,8};
	int n = sizeof(arr) / sizeof(arr[0]);
	  for (int i = (n - 1 - 1) / 2; i >= 0; i--)
	  {
		downAdjust(arr, i, n);
	  }
		for (int i = n; i > 0; )
		{
			swap(&arr[0], &arr[i - 1]);
			downAdjust(arr, 0, --i);
		}
		for (int i = 0; i < n; i++)
		{
			printf("%d ", arr[i]);
		}

	return 0;
}

topK算法

在一组数据中,选出k个最大(最小)的数

思路

如果我们选择k个最大的数,假设数组的前k个数就是最大的数,这 k个数建立 小堆,带一个数与 后面的从第 k + 1个数开始,进行比较,如果比第一个数的就换下来,然后向下调整,直到每个所有数都比较完了


代码

void downAdjust(int* pa, int parent, int n)
{
	int child = parent * 2 + 1;
	while (child < n)
	{
		if (child + 1 < n && pa[child] > pa[child + 1])
		{
			child++;
		}
		if (pa[parent] > pa[child])
		{
			swap(&pa[parent], &pa[child]);
		}
		else
		{
			break;
		}
		parent = child;
		child = parent * 2 + 1;
	}
}
#include<stdio.h>
int main()
{
	int arr[] = { 1,6,10,3,5,8,46,23,6,25,3,40 };
	int n = sizeof(arr) / sizeof(arr[0]);
	int k = 0;
	scanf("%d", &k);
	for (int i = (k - 1 - 1) / 2; i >= 0; i--)
	{
		downAdjust(arr, i, n);
	}
	for (int i = k; i < n; i++)
	{
		if (arr[i] > arr[0])
		{
			swap(&arr[i], &arr[0]);
			downAdjust(arr, 0, k);
		}
	}
	for (int i = 0; i < k; i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}

五. 二叉树的实现

1. 链接结构搭建二叉树

代码

typedef int TLType;
typedef struct TreeList
{
	TLType val;
	struct TreeList* left;
	struct TreeList* right;
}TL;
TL *creatnode(TLType x)
{
	TL*pa = (TL*)malloc(sizeof(TL));
	if (pa == NULL)
	{
		perror("malloc");
		return;
	}
	TL* newnode = pa;
	newnode->left = newnode->right = NULL;
	newnode->val = x;
	return newnode;
}
TL* CreatTree()
{
	TL* tree1 = creatnode(1);
	TL *tree2 = creatnode(2);
	TL* tree3 = creatnode(3);
	TL* tree4 = creatnode(3);
	tree1->left = tree2;
	tree1->right = tree3;
	tree2->left = tree4;
	return tree1;
}
#include<stdio.h>
int main()
{
	TL* p = NULL;
	p = CreatTree();
}

我们搭建了一个这样的树结构:

2. 二叉树的遍历

二叉树的遍历可以分三种:前序,中序,后序,层序

a. 前序遍历:(根,左子树,右子树)

举例

这棵树的前序遍历是怎样的?(包括空树,用N表示)

val1 val2 val4 N N val5 N N val3 val6 N N val7 N N


代码实现 

#include<stdio.h>
#include<stdlib.h>
typedef int TLType;
typedef struct TreeList
{
	TLType val;
	struct TreeList* left;
	struct TreeList* right;
}TL;
TL *creatnode(TLType x)
{
	TL*pa = (TL*)malloc(sizeof(TL));
	if (pa == NULL)
	{
		perror("malloc");
		return;
	}
	TL* newnode = pa;
	newnode->left = newnode->right = NULL;
	newnode->val = x;
	return newnode;
}
TL* CreatTree()
{
	TL* tree1 = creatnode(1);
	TL *tree2 = creatnode(2);
	TL* tree3 = creatnode(3);
	TL* tree4 = creatnode(4);
	TL* tree5 = creatnode(5);
	TL* tree6 = creatnode(6);
	TL* tree7 = creatnode(7);
	tree1->left = tree2;
	tree1->right = tree3;
	tree2->left = tree4;
	tree2->right = tree5;
	tree3->left = tree6;
	tree3->right = tree7;
	return tree1;
}
#include<stdio.h>
void PrevOrder(TL *root)
{
	if (root == NULL)
	{
		printf("N ");
		return;
	}
	printf("%d ", root->val);
	PrevOrder(root->left);
	PrevOrder(root->right);
}
int main()
{
	TL* p = NULL;
	p = CreatTree();
	PrevOrder(p);
}

运行结果:

b. 中序遍历:(左子树,根,右子树)

举例

这棵树的中序遍历是怎样的?(包括空树,用N表示)

N val4 N val2 N val5 N val1 N val6 N val3 N val7 N


 代码实现

#include<stdio.h>
#include<stdlib.h>
typedef int TLType;
typedef struct TreeList
{
	TLType val;
	struct TreeList* left;
	struct TreeList* right;
}TL;
TL *creatnode(TLType x)
{
	TL*pa = (TL*)malloc(sizeof(TL));
	if (pa == NULL)
	{
		perror("malloc");
		return;
	}
	TL* newnode = pa;
	newnode->left = newnode->right = NULL;
	newnode->val = x;
	return newnode;
}
TL* CreatTree()
{
	TL* tree1 = creatnode(1);
	TL *tree2 = creatnode(2);
	TL* tree3 = creatnode(3);
	TL* tree4 = creatnode(4);
	TL* tree5 = creatnode(5);
	TL* tree6 = creatnode(6);
	TL* tree7 = creatnode(7);
	tree1->left = tree2;
	tree1->right = tree3;
	tree2->left = tree4;
	tree2->right = tree5;
	tree3->left = tree6;
	tree3->right = tree7;
	return tree1;
}
#include<stdio.h>
void InOder(TL* root)
{
	if (root == NULL)
	{
		printf("N ");
		return;
	}
	InOder(root->left);
	printf("%d ", root->val);
	InOder(root->right);
}
int main()
{
	TL* p = NULL;
	p = CreatTree();
	InOder(p);
}

运行结果:

c. 后序遍历:(左子树,右子树,根)

举例

这棵树的后序遍历是怎样的?(包括空树,用N表示)

N N val4 N N val5 val2 N N val6 N N val7 val3 val1


代码实现 

#include<stdio.h>
#include<stdlib.h>
typedef int TLType;
typedef struct TreeList
{
	TLType val;
	struct TreeList* left;
	struct TreeList* right;
}TL;
TL* creatnode(TLType x)
{
	TL* pa = (TL*)malloc(sizeof(TL));
	if (pa == NULL)
	{
		perror("malloc");
		return;
	}
	TL* newnode = pa;
	newnode->left = newnode->right = NULL;
	newnode->val = x;
	return newnode;
}
TL* CreatTree()
{
	TL* tree1 = creatnode(1);
	TL* tree2 = creatnode(2);
	TL* tree3 = creatnode(3);
	TL* tree4 = creatnode(4);
	TL* tree5 = creatnode(5);
	TL* tree6 = creatnode(6);
	TL* tree7 = creatnode(7);
	tree1->left = tree2;
	tree1->right = tree3;
	tree2->left = tree4;
	tree2->right = tree5;
	tree3->left = tree6;
	tree3->right = tree7;
	return tree1;
}
void PostOder(TL* root)
{
	if (root == NULL)
	{
		printf("N ");
		return;
	}
	PostOder(root->left);
	PostOder(root->right);
	printf("%d ", root->val);
}
int main()
{
	TL* p = NULL;
	p = CreatTree();
	PostOder(p);
}

运行结果:

d. 层序遍历

一排排的遍历

画图举例

实现思路 

这里我们借助队列(可以先进先出),开辟的数组里面存放根节点的地址(通过地址可以找到左右子树,否则如果存值是没有办法找到左右子树),打印完根节点的值,就释放,存入左右子树的节点

代码实现

实现的二叉树是这样的:

#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
typedef int TLType;
typedef struct TreeList
{
	TLType val;
	struct TreeList* left;
	struct TreeList* right;
}TL;
TL* creatnode(TLType x)
{
	TL* pa = (TL*)malloc(sizeof(TL));
	if (pa == NULL)
	{
		perror("malloc");
		return;
	}
	TL* newnode = pa;
	newnode->left = newnode->right = NULL;
	newnode->val = x;
	return newnode;
}
TL* CreatTree()
{
	TL* tree1 = creatnode(1);
	TL* tree2 = creatnode(2);
	TL* tree3 = creatnode(3);
	TL* tree4 = creatnode(4);
	TL* tree5 = creatnode(5);
	TL* tree6 = creatnode(6);
	TL* tree7 = creatnode(7);
	tree1->left = tree2;
	tree1->right = tree3;
	tree2->left = tree4;
	tree2->right = tree5;
	tree3->left = tree6;
	tree3->right = tree7;
	return tree1;
}
typedef struct QueueNode
{
	struct QueueNode* next;
	TL* data;
}QNode;

typedef struct Queue
{
	QNode* head;
	QNode* tail;
	int size;
}Que;


void QueueInit(Que* pq)
{
	assert(pq);

	pq->head = pq->tail = NULL;
	pq->size = 0;
}

void QueueDestroy(Que* pq)
{
	assert(pq);

	QNode* cur = pq->head;
	while (cur)
	{
		QNode* next = cur->next;
		free(cur);
		cur = next;
	}

	pq->head = pq->tail = NULL;
	pq->size = 0;
}

void QueuePush(Que* pq, TL* x)
{
	assert(pq);

	QNode* newnode = (QNode*)malloc(sizeof(QNode));
	if (newnode == NULL)
	{
		perror("malloc fail");
		exit(-1);
	}

	newnode->data = x;
	newnode->next = NULL;

	if (pq->tail == NULL)
	{
		pq->head = pq->tail = newnode;
	}
	else
	{
		pq->tail->next = newnode;
		pq->tail = newnode;
	}

	pq->size++;
}

bool QueueEmpty(Que* pq)
{
	assert(pq);

	return pq->head == NULL;
}
void QueuePop(Que* pq)
{
	assert(pq);
	assert(!QueueEmpty(pq));

	if (pq->head->next == NULL)
	{
		free(pq->head);
		pq->head = pq->tail = NULL;
	}
	else
	{
		QNode* next = pq->head->next;
		free(pq->head);
		pq->head = next;
	}

	pq->size--;
}

TL* QueueFront(Que* pq)
{
	assert(pq);
	assert(!QueueEmpty(pq));

	return pq->head->data;
}




int QueueSize(Que* pq)
{
	assert(pq);

	return pq->size;
}
void leverOrder(TL* root, Que* pq)
{
	QueuePush(pq, root);
	while (!QueueEmpty(pq))
	{
		TL* pa = QueueFront(pq);
		printf("%d ", pa->val);
		QueuePop(pq);
		if (pa->left != NULL)
		{
			QueuePush(pq, pa->left);
		}
		if (pa->right != NULL)
		{
			QueuePush(pq, pa->right);
		}
	}

}
int main()
{
	TL* p = NULL;
	p = CreatTree();
	Que q;
	QueueInit(&q);
	leverOrder(p, &q);
	return 0;
}

运行结果:

3. 简单二叉树经典问题求解

a. 求二叉树的节点个数

思路

想要求二叉树的节点可以分成 根节点 + 左子树 + 右子树

这里的遍历类似 前序遍历

代码

实现的树是这样的:

#include<stdio.h>
#include<stdlib.h>
typedef int TLType;
typedef struct TreeList
{
	TLType val;
	struct TreeList* left;
	struct TreeList* right;
}TL;
TL* creatnode(TLType x)
{
	TL* pa = (TL*)malloc(sizeof(TL));
	if (pa == NULL)
	{
		perror("malloc");
		return;
	}
	TL* newnode = pa;
	newnode->left = newnode->right = NULL;
	newnode->val = x;
	return newnode;
}
TL* CreatTree()
{
	TL* tree1 = creatnode(1);
	TL* tree2 = creatnode(2);
	TL* tree3 = creatnode(3);
	TL* tree4 = creatnode(4);
	TL* tree5 = creatnode(5);
	TL* tree6 = creatnode(6);
	TL* tree7 = creatnode(7);
	tree1->left = tree2;
	tree1->right = tree3;
	tree2->left = tree4;
	tree2->right = tree5;
	tree3->left = tree6;
	tree3->right = tree7;
	return tree1;
}
int TreeSize(TL* root)
{
	if (root == NULL)
	{
		return 0;
	}
	return 1 + TreeSize(root->left) + TreeSize(root->right);
}
int main()
{
	TL* p = NULL;
	p = CreatTree();
	int size = TreeSize(p);
	printf("%d ", size);
	return 0;
}

b. 求树的高度

思路

求二叉树的高度,我们需要找到到那个最长的路径,这里采用分治的思想,如果为空树,返回 0 (空树高度为 0),调用左子树和右子树都会 + 1(+ 1可以理解成加上节点的高度),对比左子树和右子树,返回高度最大的那个

注:每求一次左右节点个数时,一定要保存,否则会有很大的时间浪费


代码

#include<stdio.h>
#include<stdlib.h>
typedef int TLType;
typedef struct TreeList
{
	TLType val;
	struct TreeList* left;
	struct TreeList* right;
}TL;
TL* creatnode(TLType x)
{
	TL* pa = (TL*)malloc(sizeof(TL));
	if (pa == NULL)
	{
		perror("malloc");
		return;
	}
	TL* newnode = pa;
	newnode->left = newnode->right = NULL;
	newnode->val = x;
	return newnode;
}
TL* CreatTree()
{
	TL* tree1 = creatnode(1);
	TL* tree2 = creatnode(2);
	TL* tree3 = creatnode(3);
	TL* tree4 = creatnode(4);
	TL* tree5 = creatnode(5);
	TL* tree6 = creatnode(6);
	TL* tree7 = creatnode(7);
	TL* tree8 = creatnode(8);
	tree1->left = tree2;
	tree1->right = tree3;
	tree2->left = tree4;
	tree2->right = tree5;
	tree3->left = tree6;
	tree3->right = tree7;
	tree4->left = tree8;
	return tree1;
}
int TreeHigh(TL* root)
{
	if (root == NULL)
	{
		return 0;
	}
	int Left = 1 + TreeHigh(root->left);
	int Right = 1 +  TreeHigh(root->right) ;
	return Left > Right ? Left : Right;
}
int main()
{
	TL* p = NULL;
	p = CreatTree();
	int high = TreeHigh(p);
	printf("%d ", high);
	return 0;
}

c. 求根节点的个数

思路

判断是否是根节点的方法就是判断它的左右子树是否是 空树,我们只需要遍历这棵树就行,但如果遍历时,根节点遇到空树这也是一种结束条件


代码

#include<stdio.h>
#include<stdlib.h>
typedef int TLType;
typedef struct TreeList
{
	TLType val;
	struct TreeList* left;
	struct TreeList* right;
}TL;
TL* creatnode(TLType x)
{
	TL* pa = (TL*)malloc(sizeof(TL));
	if (pa == NULL)
	{
		perror("malloc");
		return;
	}
	TL* newnode = pa;
	newnode->left = newnode->right = NULL;
	newnode->val = x;
	return newnode;
}
TL* CreatTree()
{
	TL* tree1 = creatnode(1);
	TL* tree2 = creatnode(2);
	TL* tree3 = creatnode(3);
	TL* tree4 = creatnode(4);
	TL* tree5 = creatnode(5);
	TL* tree6 = creatnode(6);
	TL* tree7 = creatnode(7);
	TL* tree8 = creatnode(8);
	tree1->left = tree2;
	tree1->right = tree3;
	tree2->left = tree4;
	tree2->right = tree5;
	tree3->left = tree6;
	tree3->right = tree7;
	tree4->left = tree8;
	return tree1;
}
int RootSize(TL* root)
{
	if (root == NULL)
	{
		return 0;
	}
	if (root->left == NULL && root->right == NULL)
	{
		return 1;
	}
	return RootSize(root->left) + RootSize(root->right);
}
int main()
{
	TL* p = NULL;
	p = CreatTree();
	int root = RootSize(p);
	printf("%d ", root);
	return 0;
}

d. 求倒数第k排节点的个数

思路

这个可以是求树的高度的变形,将计数倒过来


代码 

#include<stdio.h>
#include<stdlib.h>
typedef int TLType;
typedef struct TreeList
{
	TLType val;
	struct TreeList* left;
	struct TreeList* right;
}TL;
TL* creatnode(TLType x)
{
	TL* pa = (TL*)malloc(sizeof(TL));
	if (pa == NULL)
	{
		perror("malloc");
		return;
	}
	TL* newnode = pa;
	newnode->left = newnode->right = NULL;
	newnode->val = x;
	return newnode;
}
TL* CreatTree()
{
	TL* tree1 = creatnode(1);
	TL* tree2 = creatnode(2);
	TL* tree3 = creatnode(3);
	TL* tree4 = creatnode(4);
	TL* tree5 = creatnode(5);
	TL* tree6 = creatnode(6);
	TL* tree7 = creatnode(7);
	TL* tree8 = creatnode(8);
	tree1->left = tree2;
	tree1->right = tree3;
	tree2->left = tree4;
	tree2->right = tree5;
	tree3->left = tree6;
	tree3->right = tree7;
	tree4->left = tree8;
	return tree1;
}

int TreeHigh(TL* root)
{
	if (root == NULL)
	{
		return 0;
	}
	int Left = 1 + TreeHigh(root->left);
	int Right = 1 +  TreeHigh(root->right) ;
	return Left > Right ? Left : Right;
}
int RootKsize(TL* root,int n,int k)
{
	if (root == NULL)
	{
		return 0;
	}
	if (n == k)
	{
		return 1;
	}
	return RootKsize(root->left, n - 1, k) + RootKsize(root->right, n - 1, k);
}
int main()
{
	int k = 0;
	scanf("%d", &k);
	TL* p = NULL;
	p = CreatTree();
	int high = TreeHigh(p);
	int rootk = RootKsize(p, high, k);
	printf("%d ", rootk);
	return 0;
}

e. 判断是否是相同的树

思路

采用前序,先比较根节点是否相同,再比较左右子树是否相同

代码

#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
typedef int TLType;
typedef struct TreeList
{
	TLType val;
	struct TreeList* left;
	struct TreeList* right;
}TL;
TL* creatnode(TLType x)
{
	TL* pa = (TL*)malloc(sizeof(TL));
	if (pa == NULL)
	{
		perror("malloc");
		return;
	}
	TL* newnode = pa;
	newnode->left = newnode->right = NULL;
	newnode->val = x;
	return newnode;
}
TL* CreatTree1()
{
	TL* tree1 = creatnode(1);
	TL* tree2 = creatnode(2);
	TL* tree3 = creatnode(3);
	TL* tree4 = creatnode(4);
	TL* tree5 = creatnode(5);
	TL* tree6 = creatnode(6);
	TL* tree7 = creatnode(7);
	TL* tree8 = creatnode(8);
	tree1->left = tree2;
	tree1->right = tree3;
	tree2->left = tree4;
	tree2->right = tree5;
	tree3->left = tree6;
	tree3->right = tree7;
	tree4->left = tree8;
	return tree1;
}
TL* CreatTree2()
{
	TL* tree1 = creatnode(1);
	TL* tree2 = creatnode(2);
	TL* tree3 = creatnode(3);
	TL* tree4 = creatnode(4);
	TL* tree5 = creatnode(5);
	TL* tree6 = creatnode(6);
	TL* tree7 = creatnode(7);
	tree1->left = tree2;
	tree1->right = tree3;
	tree2->left = tree4;
	tree2->right = tree5;
	tree3->left = tree6;
	tree3->right = tree7;
	return tree1;
}
bool IsSameTree(TL* root1,TL* root2)
{
	if (root1 == NULL && root2 == NULL)
	{
		return true;
	}
	if (root1 == NULL || root2 == NULL)
	{
		return false;
	}
	if (root1->val != root2->val)
	{
		return false;
	}
	return IsSameTree(root1->left, root2->left) && IsSameTree(root1->right, root2->right);
}
int main()
{
	TL* p = NULL;
	p = CreatTree1();
	TL* q = CreatTree2();
	printf("%d ", IsSameTree(p, q));
	return 0;
}

f. 找到某个值,返回节点的地址

思路

前序遍历完数组,如果对比左右子树,判断是否找到节点的地址

代码

#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
typedef int TLType;
typedef struct TreeList
{
	TLType val;
	struct TreeList* left;
	struct TreeList* right;
}TL;
TL* creatnode(TLType x)
{
	TL* pa = (TL*)malloc(sizeof(TL));
	if (pa == NULL)
	{
		perror("malloc");
		return;
	}
	TL* newnode = pa;
	newnode->left = newnode->right = NULL;
	newnode->val = x;
	return newnode;
}
TL* CreatTree()
{
	TL* tree1 = creatnode(1);
	TL* tree2 = creatnode(2);
	TL* tree3 = creatnode(2);
	TL* tree4 = creatnode(4);
	TL* tree5 = creatnode(5);
	TL* tree6 = creatnode(6);
	TL* tree7 = creatnode(7);
	TL* tree8 = creatnode(8);
	tree1->left = tree2;
	tree1->right = tree3;
	tree2->left = tree4;
	tree2->right = tree5;
	tree3->left = tree6;
	tree3->right = tree7;
	tree4->left = tree8;
	return tree1;
}
TL* FindRoot(TL* root,int m)
{
	if (root == NULL)
	{
		return NULL;
	}
	if (root->val == m)
	{
		return root;
	}
	TL* Left = FindRoot(root->left, m);
	TL* Right = FindRoot(root->right, m);
	if (Left == NULL && Right == NULL)
	{
		return NULL;
	}
	if (Left == NULL && Right != NULL)
	{
		return Right;
	}
	else 
	{
		return Left;
	}
	
}
int main()
{
	TL* p = NULL;
	p = CreatTree();
	int m = 0;
	scanf("%d", &m);
	TL *root = FindRoot(p,m);
	if (root == NULL)
	{
		printf("找不到\n");
	}
	else
	{
		printf("%d ", root->val);
	}
	return 0;
}

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

boss app sig及sp参数,魔改base64

前言 大家好呀,欢迎来到我的博客.2023年12月4日,boss web上线了最新的zp_token,环境检测点又增加了,与此同时app端的关键加密so从32位换成了64位,两者ida反编译so的时候都有反调试,无法直接f5,需要手动调整让ida重新识别.google了一下几乎找不到任何有关boss app的文章,所以这…

luceda ipkiss教程 53:在版图上加中文

要在版图上加中文&#xff0c;如&#xff1a; 可以通过如下方法实现&#xff1a; 首先&#xff0c;可以在ppt中加入文本框&#xff0c;在文本框中输入想要加到版图上的中文内容&#xff0c;如&#xff0c;复旦大学&#xff0c;并将文本框存为windows位图。 其次&#xff0c;通…

java八股 mysql优化

数据库篇-01-MySQL篇-课程介绍_哔哩哔哩_bilibili 1.定位慢查询 2.分析优化慢查询 3.索引概念及结构 3.1 红黑树&#xff08;一种自平衡的二叉排序树&#xff09; 节点可以自动平衡保证log2 n的查找复杂度. 但因为是二叉树&#xff0c;数据多了层数还会多。 所以找一个多叉树 3…

【MCAL】TC397+EB-treso之MCU配置实战 - 芯片时钟

本篇文章介绍了在TC397平台使用EB-treso对MCU驱动模块进行配置的实战过程&#xff0c;主要介绍了后续基本每个外设模块都要涉及的芯片时钟部分&#xff0c;帮助读者了解TC397芯片的时钟树结构&#xff0c;在后续计算配置不同外设模块诸如通信速率&#xff0c;定时器周期等&…

项目管理4321方法论

文章目录 一、项目立项准备&#xff08;4步&#xff09;case1、识别价值---解决背后痛点的才是价值&#xff0c;价值是做任何事情的出发点case2、明确目标---支撑价值实现的&#xff0c;目标是 具体/可衡量/可达到/相关性/有时限的case3、识别干系人---找对人才能做对事&#x…

Android画布Canvas裁剪clipRect,Kotlin

Android画布Canvas裁剪clipRect&#xff0c;Kotlin private fun mydraw() {val originBmp BitmapFactory.decodeResource(resources, R.mipmap.pic).copy(Bitmap.Config.ARGB_8888, true)val newBmp Bitmap.createBitmap(originBmp.width, originBmp.height, Bitmap.Config.A…

差生文具多之(二): perf

栈回溯和符号解析是使用 perf 的两大阻力&#xff0c;本文以应用程序 fio 的观测为例子&#xff0c;提供一些处理它们的经验法则&#xff0c;希望帮助大家无痛使用 perf。 前言 系统级性能优化通常包括两个阶段&#xff1a;性能剖析和代码优化&#xff1a; 性能剖析的目标是寻…

[Unity]接入Firebase 并且关联支付埋点

首先 在这个下一下FireBase的资源 firebase11.0.6 然后导入Analytics Auth Crashlytics 其他的看着加就行 然后直接丢到Unity里面 接下来需要去Firebase里面下载 Google json 丢到 这个下面 然后就是脚本代码了 using System.Collections; using System.Collection…

从mice到missForest:常用数据插值方法优缺点

一、引言 数据插值方法在数据处理和分析中扮演着至关重要的角色。它们可以帮助我们处理缺失数据&#xff0c;使得数据分析更加准确和可靠。数据插值方法被广泛应用于金融、医疗、社会科学等领域&#xff0c;以及工程和环境监测等实际应用中。 在本文中&#xff0c;我们将探讨三…

【教学类-42-02】20231224 X-Y 之间加法题判断题2.0(按2:8比例抽取正确题和错误题)

作品展示&#xff1a; 0-5&#xff1a; 21题&#xff0c;正确21题&#xff0c;错误21题42题 。小于44格子&#xff0c;都写上&#xff0c;哪怕输入2:8&#xff0c;实际也是5:5 0-10 66题&#xff0c;正确66题&#xff0c;错误66题132题 大于44格子&#xff0c;正确66题抽取44*…

php反序列化漏洞原理、利用方法、危害

文章目录 PHP反序列化漏洞1. 什么是PHP反序列化漏洞&#xff1f;2. PHP反序列化如何工作&#xff1f;3. PHP反序列化漏洞是如何利用的&#xff1f;4. PHP反序列化漏洞的危害是什么&#xff1f;5. 如何防止PHP反序列化漏洞&#xff1f;6. PHP反序列化漏洞示例常见例子利用方法PH…

DaVinci各版本安装指南

链接: https://pan.baidu.com/s/1g1kaXZxcw-etsJENiW2IUQ?pwd0531 ​ #2024版 1.鼠标右击【DaVinci_Resolve_Studio_18.5(64bit)】压缩包&#xff08;win11及以上系统需先点击“显示更多选项”&#xff09;【解压到 DaVinci_Resolve_Studio_18.5(64bit)】。 2.打开解压后的文…

插入排序之C++实现

描述 插入排序是一种简单直观的排序算法。它的基本思想是将一个待排序的数据序列分为已排序和未排序两部分&#xff0c;每次从未排序序列中取出一个元素&#xff0c;然后将它插入到已排序序列的适当位置&#xff0c;直到所有元素都插入完毕&#xff0c;即完成排序。 实现思路…

【c++】string类的使用

目录 一、标准库中的string类 1、简单介绍string类 2、string类的常用接口注意事项 2.1、string类对象的常用构造 2.2、string类对象的容量操作 2.3、string类对象的访问及遍历操作 2.4、string类对象的修改操作 二、string类的模拟实现 一、标准库中的string类 1、简…

jQuery: 整理3---操作元素的内容

1.html("内容") ->设置元素的内容&#xff0c;包含html标签&#xff08;非表单元素&#xff09; <div id"html1"></div><div id"html2"></div>$("#html1").html("<h2>上海</h2>") …

【期末考试】计算机网络、网络及其计算 考试重点

个人简介&#xff1a;Java领域新星创作者&#xff1b;阿里云技术博主、星级博主、专家博主&#xff1b;正在Java学习的路上摸爬滚打&#xff0c;记录学习的过程~ 个人主页&#xff1a;.29.的博客 学习社区&#xff1a;进去逛一逛~ 计算机网络及其计算 期末考点 &#x1f680;数…

Flink 客户端操作命令及可视化工具

Flink提供了丰富的客户端操作来提交任务和与任务进行交互。下面主要从Flink命令行、Scala Shell、SQL Client、Restful API和 Web五个方面进行整理。 在Flink安装目录的bin目录下可以看到flink&#xff0c;start-scala-shell.sh和sql-client.sh等文件&#xff0c;这些都是客户…

面向船舶结构健康监测的数据采集与处理系统(一)系统架构

世界贸易快速发展起始于航海时代&#xff0c;而船舶作为重要的水上交通工具&#xff0c;有 其装载量大&#xff0c;运费低廉等优势。但船舶在运营过程中出现的某些结构处应力值 过大问题往往会给运营部门造成重大的损失&#xff0c;甚至造成大量的人员伤亡和严重 的环境污染…

【网络安全/CTF】unseping 江苏工匠杯

该题考察序列化反序列化及Linux命令执行相关知识。 题目 <?php highlight_file(__FILE__);class ease{private $method;private $args;function __construct($method, $args) {$this->method $method;$this->args $args;}function __destruct(){if (in_array($thi…