数据结构与算法
lininnnn
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
十进制数转化为任意进制
//十进制数转化为任意进制 #include "stdafx.h" #define L 10 void c(int N, int r); int main() { c(3467,8); return 0; } void c(int N,int r) { int s[L], top; int x; top = -1; while (N!=0) { s[++top] = ...原创 2019-01-10 22:50:46 · 553 阅读 · 0 评论 -
构造哈夫曼树
缺点:在找最小值和次小次时,会比已经匹配过的点再重新比较一次,有点浪费。 以后算法学好了再回来看看有什么可以更好的实现方法吧 #include "stdafx.h" #define N 10 //结点个数 #define MAXVALUE 1000000 //作比较用 typedef struct { int weight; //权值 int parent; int lch...原创 2019-01-18 00:17:51 · 1105 阅读 · 0 评论 -
表达式求值,后缀表达式
思路:用一个栈保存数字,从左往右扫描字符串,遇到数字就存进入栈中,遇到运算符就从栈中取两个数字进行运算。 #include "stdafx.h" #include<cstdlib> #include<iostream> #include<stack> #include <string> using namespace std; int ope...原创 2019-01-13 13:56:48 · 261 阅读 · 0 评论 -
先序遍历,非递归
typedef struct { int data; btNode* leftChild; btNode* rightChild; }btNode; int firstVisit(btNode *p) { btNode* b; b = p; stack<btNode*> _stack; while (!(b==nullptr&&_stack.e...原创 2019-01-14 23:33:39 · 1806 阅读 · 0 评论 -
二分查找
#include "stdafx.h" #include<iostream> using namespace std; int BinarySearch(int *a,int x); int main() { int a[17] = {1,5,7,8,9,12,15,20,32,50,78,95,101,120,130,135}; int x = 15; int result...原创 2019-01-16 22:19:27 · 141 阅读 · 0 评论
分享