![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
Daimorpher
这个作者很懒,什么都没留下…
展开
-
请设计时间和空间上都尽可能高效的算法,求链式存储的线性表的倒数第m个元素
#includeusing namespace std;typedef struct PolyNode * Polynomial;struct PolyNode { int Data; Polynomial link;};void Attach(int data, Polynomial * PtrRear){ Polynomial P= new struct PolyNode;原创 2017-11-10 16:44:51 · 6942 阅读 · 0 评论 -
7-3 树的同构(25 分)
#include<iostream>using namespace std;const int Maxsize = 20;struct Node { char Data; int Left, Right;}T1[Maxsize], T2[Maxsize];typedef struct Node Tree;int check[Maxsize];void Initial...原创 2018-01-01 18:07:51 · 1053 阅读 · 0 评论 -
7-4 是否同一棵二叉搜索树
#include<iostream>using namespace std;typedef struct Node * Tree;struct Node { int Data; Tree Left, Right; int flag;};Tree NewNode(int tmp){ Tree T = new struct Node; T->Data = tm...原创 2018-01-01 22:50:13 · 566 阅读 · 0 评论 -
汉诺塔问题的递归解法与非递归解法(堆栈解法)
1.非递归解法,使用堆栈主要是将问题分解为三个,从后向前压进堆栈,再依次解决#includeusing namespace std;const int Maxsize = 100;typedef struct { //建立一个汉诺塔模型,n是盘个数,ABC是三个柱子 int N; char A; char B; char C;}Mode;typedef struc转载 2017-11-13 22:15:13 · 3551 阅读 · 1 评论 -
二分法查找已排序数列中目标数字的位置
#includeusing namespace std;int search(int list[], int n,int find){ int start = 0, end = n - 1; while (start <= end) { int middle = (start + end) / 2; if (find == list[middle]) return m原创 2017-11-02 21:54:43 · 2357 阅读 · 0 评论 -
将制定整数插入到数组(数组已排序完成),插入后保持结果有序
#includeusing namespace std;void search(int list[], int list2[], int n, int x){ int target = 0, i; for (i = 0; i < n; i++) if (x < list[i]) break; target = i; for (int j = 0; j < target原创 2017-11-02 21:43:49 · 923 阅读 · 0 评论 -
质数判断程序
#includeusing namespace std;int main(){ int n; cin >> n; int count=0; for (int i = 2; i <= n - 1; i++) { if (n%i == 0) count++; } if (count == 0) cout << "yes"; else cout << "no";原创 2017-11-02 21:38:48 · 4982 阅读 · 0 评论 -
两个链式存储的一元多项式乘法运算算法
#includeusing namespace std;typedef struct PolyNode * Polynomial;struct PolyNode { int coef; int expon; Polynomial link;};void Attach(int c, int e, Polynomial * Rear){ Polynomial P = new str原创 2017-11-11 16:54:18 · 4818 阅读 · 2 评论 -
7-2 一元多项式的乘法与加法运算(20 分)
#include<iostream>using namespace std;typedef struct LNode * List;struct LNode { int coef; int expon; List Next;};void Attach(List L, int coef, int expon){ if (!L) { L->coef = c...原创 2017-12-31 22:29:37 · 3550 阅读 · 1 评论