![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
文章平均质量分 74
chpstudy
这个作者很懒,什么都没留下…
展开
-
二叉树的创建以及前序、中序、后序遍历
// hello.cpp : Defines the entry point for the console application.//#include "stdafx.h"//#include#include #include //二叉树结点结构typedef struct BiTNode {char ch;//结点数据struct BiTN转载 2017-04-07 08:56:28 · 337 阅读 · 0 评论 -
poj[3984]
#includeusing namespace std;#define QSize 50int a[5][5];int dis[4][2]={ {-1,0},{1,0},{0,-1},{0,1} };struct Node{ int x, y, pre;}queue[QSize];int front = 0;int rear = 0;int visit[5][5];原创 2017-05-16 21:53:14 · 778 阅读 · 0 评论 -
关于堆得相关操作
#include#include#include#define INIT_ARRAY_SIZE 50using namespace std;int heap_size;int heap_cap_size;void build_heap(int array[], int length);void max_heap_adjust(int array[], int index);原创 2017-05-16 20:31:37 · 364 阅读 · 0 评论 -
一个简单的双端链表实现过程
//Author:Pei Chen//Date:2017.04.30#include#includetypedef int ElemType;typedef struct Node{ ElemType data; struct Node *prior; struct Node* next;}Node,*DLinkList;DLinkList DLinkListCrea原创 2017-04-30 17:49:04 · 713 阅读 · 0 评论 -
线索二叉树
一、线索二叉树的原理 通过考察各种二叉链表,不管儿叉树的形态如何,空链域的个数总是多过非空链域的个数。准确的说,n各结点的二叉链表共有2n个链域,非空链域为n-1个,但其中的空链域却有n+1个。如下图所示。 因此,提出了一种方法,利用原来的空链域存放指针,指向树中其他结点。这种指针称为线索。 记ptr指向二叉链表中的一个结点,以下是建立线索的规原创 2017-04-13 22:09:04 · 265 阅读 · 0 评论 -
用堆栈实现由十进制数向其他进制的转换
#include"Stack.h"#include#include"TryStack.h"#include#define _CRT_SECURE_NO_DEPRECATE#define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1void convert(Stack &s, int N,int n){ InitStack(&s); do原创 2017-04-13 19:54:38 · 1453 阅读 · 0 评论 -
堆栈的工作原理
#pragma once#ifndef STACK_H#define STACK_H#define INFINITY 65535 //表示无穷大#define MAXSIZE 1000 //栈的最大空间typedef int ElemType; //栈的数据类型#include"Stack.h"#includeint main(){ Stack s; InitStack(&原创 2017-04-10 09:20:14 · 629 阅读 · 0 评论 -
循环队列的实现
#include#include#includeusing namespace std;typedef int QElementType;typedef int status;#define _ERROR 0#define _OK 1#define MAXQSIZE 10//队列的数据抽象typedef struct{ QElementType *base;//原创 2017-04-09 20:26:16 · 379 阅读 · 0 评论 -
求二叉树叶子结点的个数
#include#define N 63using namespace std;char str[] = "ab#d##c#e##";int i = -1;typedef struct node{char data;struct node *leftChild;struct node *rightChild;}BiTreeNo原创 2017-04-07 09:37:02 · 2384 阅读 · 0 评论 -
求一个简单的二叉树的深度
#include"stdafx.h"#includeusing namespace std;struct BinaryTreeNode{int m_nValue;BinaryTreeNode* m_pLeft;BinaryTreeNode* m_pRight;};//创建二叉树结点BinaryTreeNode* CreateB原创 2017-04-07 08:57:35 · 401 阅读 · 0 评论 -
中国剩余定理与韩信点兵问题原理
秦王暗点兵问题和韩信乱点兵问题,都是后人对物不知其数问题的一种故事化.物不知其数问题出自一千六百年前我国古代数学名著《孙子算经》.原题为:"今有物不知其数,三三数之二,五五数之三,七七数之二,问物几何?"这道题的意思是:有一批物品,不知道有几件.如果三件三件地数,就会剩下两件;如果五件五件地数,就会剩下三件;如果七件七件地数,也会剩下两件.问:这批物品共有多少件?变成一个纯粹的数学问题原创 2017-05-20 14:54:01 · 1714 阅读 · 0 评论