摘要: 试题 算法训练 跳马(BFS) #include <iostream> #include <algorithm> #include <cstring> #include <queue> using namespace std; int dir[8][2] = {{-2, -1}, {-2, 1}, {-1, -2}, {-1, 2 阅读全文
posted @ 2022-02-07 20:28 帝宝单推人! 阅读(182) 评论(0) 推荐(0)
摘要: 美图素材(贴贴) 阅读全文
posted @ 2022-01-28 22:49 帝宝单推人! 阅读(119) 评论(0) 推荐(0)
摘要: 二叉树的层序遍历,用堆栈先序遍历,递归树的深度 ##队列实现层序遍历,以及改为堆栈先序遍历 #include<iostream> using namespace std; typedef int ElemType; typedef struct BinTree { ElemType data; struct BinTree* Left; stru 阅读全文
posted @ 2022-01-28 22:40 帝宝单推人! 阅读(79) 评论(0) 推荐(0)
摘要: 二叉树的三种递归与非递归遍历 ##递归遍历 #include<iostream> using namespace std; typedef struct BinTree { ElemType data; struct BinTree* Left; struct BinTree* Right; }BinTree; void Pos 阅读全文
posted @ 2022-01-28 19:29 帝宝单推人! 阅读(43) 评论(0) 推荐(0)
摘要: 队列 ##队列的顺序存储 #include<iostream> using namespace std; #define MaxSize 10 #define ERROR 0 #define TRUE 1 typedef int ElemType; typedef struct QNode { ElemT 阅读全文
posted @ 2022-01-27 14:36 帝宝单推人! 阅读(30) 评论(0) 推荐(0)
摘要: 堆栈 ##顺序储存 #include<iostream> using namespace std; #define MaxSize 10 const ERROR=0; const TRUE=1; typedef int ElemType; typedef struct Snode { ElemType d 阅读全文
posted @ 2022-01-27 10:50 帝宝单推人! 阅读(31) 评论(0) 推荐(0)
摘要: 链表的实现 ##顺序表的链式存储 #include <iostream> using namespace std; typedef int ElemType; typedef struct LinkList { ElemType value; struct LinkList *next; } LinkList; 阅读全文
posted @ 2022-01-26 23:40 帝宝单推人! 阅读(34) 评论(0) 推荐(0)
摘要: 顺序表的实现 网课笔记 #include <iostream> using namespace std; typedef int ElemType; typedef struct { ElemType *data; int size; int length; } SqList; bool InitList(SqL 阅读全文
posted @ 2022-01-26 11:21 帝宝单推人! 阅读(39) 评论(0) 推荐(0)
摘要: #暴力 依据素数定义,将每个数循环次$\sqrt{n}\(,一共有n个数,时间复杂度为O(n\)\sqrt{n}$). #include <stdio.h> int prime(int n) { if (n == 1) return 0; int cnt = 0; for (int i = 2; i 阅读全文
posted @ 2021-12-01 00:07 帝宝单推人! 阅读(36) 评论(0) 推荐(0)
摘要: #介绍 二分查找也称折半查找(Binary Search),它是一种效率较高的查找方法。但是,折半查找要求线性表必须采用顺序存储结构,而且表中元素按关键字有序排列. #基本思想 对有序序列进行折半操作,逐渐缩小所要查找的数据范围. 二分查找相比于顺序查找更快速,时间复杂度从O(n)优化到O(logn 阅读全文
posted @ 2021-11-27 18:22 帝宝单推人! 阅读(68) 评论(0) 推荐(0)