NOJ题解
西工大online judge
xjsc01
这个作者很懒,什么都没留下…
展开
-
二叉排序树的合并(严3.98)--------西工大noj
二叉排序树的合并有三种方法先存入数组,然后。。。。。直接在第二个树上添加第一个数的元素,时间复杂度为O(NlogN)就像是合并数组一样合并二叉排序树,分别扫描,时间复杂度极低。第三种我写了一下,是错误的答案,实在想不出更好的方法。网上还有按照方法1进行。。。方法二可能更加正常一点,虽然时间复杂度比方法一大。。。代码#include <stdio.h>#include <stdlib.h>#include <string.h>typedef s原创 2022-05-14 11:05:25 · 451 阅读 · 0 评论 -
基于图的广度优先搜索策略(耿7.11)--------西工大noj.20
目录代码代码#include <stdio.h>#include <stdlib.h>#include <string.h>typedef struct ArcNode{ int to; struct ArcNode *next; int w;}ArcNode;typedef struct VertexNode{ int data; ArcNode *arc;}VertexNode...原创 2022-04-22 21:19:29 · 169 阅读 · 0 评论 -
基于图的深度优先搜索策略(耿7.10)--------西工大noj
代码 代码#include <stdio.h>#include <stdlib.h>#include <string.h>typedef struct ArcNode{ int to; struct ArcNode *next; int w;}ArcNode;typedef struct VertexNode{ int data; ArcNode *arc;}VertexNode;typedef原创 2022-04-22 20:57:09 · 236 阅读 · 0 评论 -
输出以二叉树表示的算术表达式(严6.51)--------西工大noj
题解这道题目说的很诡异,其实没有什么把括号补上。。。。仅仅是先序读入,然后中序输出就行了代码#include <stdio.h>#include <stdlib.h>#include <string.h>typedef struct TreeNode{ char data; struct TreeNode *LChild, *RChild;}TreeNode;char *c;void Create(TreeNode ...原创 2022-04-17 10:30:03 · 457 阅读 · 0 评论 -
建立二叉树的二叉链表(严6.65)--------西工大noj
需要注意的点:在创建二叉树的函数中,如果len1==len2==0,一定要把(*T)置为NULL然后退出循环#include <stdio.h>#include <stdlib.h>#include <string.h>typedef struct TreeNode{ char data; struct TreeNode* LChild, *RChild;}TreeNode;void Create(TreeNode** T, .原创 2022-04-17 10:18:45 · 882 阅读 · 0 评论 -
建立二叉树的二叉链表存储结构(严6.70)--------西工大noj
#include <stdio.h>#include <stdlib.h>#include <string.h>typedef struct TreeNode{ char data; struct TreeNode *LChild, *RChild;}TreeNode;void Create(TreeNode **T, char *s, int len){ if(len==1) { (*T) = (...原创 2022-04-16 22:16:52 · 842 阅读 · 0 评论 -
求广义表深度(严5.30)--------西工大noj
#include <stdio.h>#include <stdlib.h>#include <string.h>typedef enum{ATOM, LIST}ElemType;typedef struct GLNode{ ElemType tag; union{ char atom; struct{ struct GLNode *hp,*tp; }htp; ...原创 2022-04-14 21:06:23 · 144 阅读 · 0 评论 -
以十字链表为存储结构实现矩阵相加(严5.27)--------西工大noj
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>typedef int ElemType;typedef struct Node{ int row, col; ElemType data; struct Node* right, * down;}Node;typedef struct CrossLink{ Node* row_head;...原创 2022-04-05 22:22:32 · 486 阅读 · 0 评论 -
以三元组表为存储结构实现矩阵相加(耿5.7)----------西工大 noj
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>#include <string.h>typedef struct _Triple{ int i; int j; int e;}Triple;typedef struct _Matrix{ Triple* data; int* i_pos; int m, n,...原创 2022-04-04 23:54:25 · 375 阅读 · 0 评论 -
循环队列(严3.30)--------西工大NOJ习题.9
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <stdlib.h>typedef struct _Queue{ int max_size; int rear; int lenth; int* data;}Queue;Queue* Create(int n){ Queue* Q = (Queue*)malloc(sizeof(Queue)); ...原创 2022-03-30 00:06:38 · 452 阅读 · 0 评论 -
K阶斐波那契数列--------西工大NOJ习题.10
科普:k阶斐波那契数列的0到n-1项需要有初始值。其中,0到n-2项初始化为0,第n-1项初始化为1.在这道题目中,所引用的函数详见:数据结构实现——循环队列(我的一篇博文)我使用的方法是尺取法,这样可以大大地减小时间复杂度。具体见代码:原创 2022-03-25 18:50:03 · 1799 阅读 · 0 评论