![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
笔记
做小孩那桌
愚昧无知是爱情
展开
-
数据结构kmp算法next函数
void get_next(char *T,int *next) { int i = 1,j = 0; next[1] = 0; while( i < strlen(T) ) { if(j == 0 || T[i-1] == T[j-1]){ next[++i] = ++j; } else { j = next[j]; } } }原创 2021-11-08 11:07:39 · 303 阅读 · 0 评论 -
数据结构 循环队列代码(顺序存储结构)
#include <stdio.h> #include <stdlib.h> //#define MaxSize 10 struct Queue { int * Data; // 动态分配存储空间 int Front; // 队头 int Rear; // 队尾 int Size; // 队列中元素个数 int MaxSize; // 队列最大容量 }; struct Queue create() { struct Queue p; p.MaxSize = 10原创 2021-11-07 22:52:17 · 74 阅读 · 0 评论 -
数据结构返回父节点
编写函数 Father,对二叉树 T 中的给定结点 P,返回 P 的父结点指针;若 P 为根结点,返回 NULL。 struct TreeNode *Father(struct TreeNode *T,struct TreeNode *P) { struct TreeNode*K; K=NULL; if(T==NULL||T==P) { return NULL; } if(T->Left!=NULL && T->Left == P) { return T-&原创 2021-11-07 22:44:47 · 802 阅读 · 1 评论 -
数据结构复制二叉树
struct TreeNode * TreeCopy(struct TreeNode *T,struct TreeNode *K) { if(T!=NULL) { struct TreeNode *Copy; Copy = (struct TreeNode *)malloc(sizeof(struct TreeNode)); Copy->Data = T->Data; Copy->Left = NULL; Copy->Right = NULL; K = C原创 2021-11-07 22:43:01 · 153 阅读 · 0 评论 -
数据结构 返回叶结点个数
int Count(struct TreeNode *T) { if(T==NULL) { return 0; } else { return 1+Count(T->Left)+Count(T->Right); } }原创 2021-11-07 22:39:32 · 126 阅读 · 0 评论 -
数据结构 二叉树返回结点个数
int Count(struct TreeNode *T) { if(T==NULL) { return 0; } else { return 1+Count(T->Left)+Count(T->Right); } }原创 2021-11-07 22:38:13 · 557 阅读 · 0 评论