摘要: 隐示意图如何使用 阅读全文
posted @ 2020-02-05 23:05 nefuer 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 树的非递归遍历 1 void preorderTravel(Tree *T){ 2 if(T==NULL){ 3 return; 4 } 5 stack<TreeNode *> S; 6 s.push(T); 7 8 while(!S.empty()){ 9 TreeNode *p = S.top( 阅读全文
posted @ 2019-12-16 22:45 nefuer 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 用数组表示 1 #include<iostream> 2 3 using namespace std; 4 5 int main(){ 6 int a[30]; 7 bool visited[30]; 8 for(int i=0; i<30; i++){ 9 cout<<i+1<<" "; 10 a 阅读全文
posted @ 2019-11-13 20:44 nefuer 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 非递归求树的宽度 以后再写 递归求树的宽度 /** *递归求二叉树宽度 */ //记录每层的节点数 int count[100]; //最宽的层的宽度, 即所求树的宽度 int MaxWidth=0; int findWidth(Tree *T, int deep){ if(!T){ return 阅读全文
posted @ 2019-11-06 11:09 nefuer 阅读(1116) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 *判断两棵树是否相似 3 */ 4 bool isSimilar(Tree T1, Tree T2){ 5 if(!T1 && !T2){ 6 return true; 7 }else(T1 && T2){ 8 return isSimilar(T1->left, T2->left) 阅读全文
posted @ 2019-11-06 10:49 nefuer 阅读(366) 评论(0) 推荐(0) 编辑
摘要: 前序中序遍历建立二叉树 1 Node * createTree1(string pres, string cens) { 2 if(pres.size() == 0 || cens.size() == 0) { 3 return nullptr; 4 } 5 Node * node = new No 阅读全文
posted @ 2019-11-06 10:43 nefuer 阅读(145) 评论(0) 推荐(0) 编辑
摘要: Floyd 多源最短路径 先看这个理解思路 https://www.cnblogs.com/wangyuliang/p/9216365.html 看这个提高,找路径 https://blog.csdn.net/qq_35644234/article/details/60875818 Dijkstra 阅读全文
posted @ 2019-11-06 08:42 nefuer 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <algorithm> 3 4 using namespace std; 5 const int MaxNum = 100; 6 const int INF = 99999; 7 typedef struct srcNode { 8 阅读全文
posted @ 2019-10-29 20:43 nefuer 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 1 #include<iostream> 2 using namespace std; 3 4 typedef struct Node{ 5 int data; 6 struct Node *next; 7 }Node; 8 9 //头插法建立链表 10 Node *createListFromHead(int a[], int n){ 11 Node *A = new Node(); 12 A- 阅读全文
posted @ 2019-10-28 20:02 nefuer 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 常见的排序 直接插入排序、二分插入排序、希尔排序、冒泡排序、快排、简单选择排序、归并排序 阅读全文
posted @ 2019-10-20 10:37 nefuer 阅读(205) 评论(0) 推荐(0) 编辑