数据结构
柠栀凉
爱疯爱笑爱胡闹
展开
-
快速排序
快速排序 #include <iostream> using namespace std; void print(int array[],int beg,int end){ for(int i=beg;i<=end;i++) printf("%d ",array[i]); printf("\n"); } void quick_sort(int array[],...原创 2019-10-25 11:49:02 · 143 阅读 · 0 评论 -
将属于同一个存储池的两个静态链表合并
void Merge(cursor M, cursor N); 合并的方法是将N链表中的所有结点添加到M链表的后面,并将N链表的表头结点添加到空闲结点链表中。要求:1、定义静态链表的结点的结构以及结点的型SPACE以及位置(position)和游标(cursor)的型。2、定义静态链表的基本操作:void Initialize(); 初始化,将所有存储池中的结点设置为空闲;cursor GetNo...原创 2018-06-05 09:35:10 · 723 阅读 · 0 评论 -
合并两个已排序的线性表——顺序表
写一个算法合并两个已排序的线性表。(用两种方法:数组表示的线性表(顺序表)和指针表示的线性表(链表)) 要求:1、定义线性表节点的结构,并定义节点的型和位置的型。 2、定义线性表的基本操作 3、在1,2的基础上,完成本题。 4、在main函数中进行测试:先构建两个有序的线性表,然后合并这两个线性表。#include <st...原创 2018-05-30 10:45:59 · 7211 阅读 · 4 评论 -
二叉树 建立 遍历 计算深度 计算节点个数
#include <stdio.h> #define max(x,y) (x>y)?x:y typedef char Elementtype; struct node{ Elementtype data; struct node *lchild,*rchild; }; node *BTREE; //先序序列建立二叉树 char *str="ABD*G***CE**F**"...原创 2018-07-01 11:12:22 · 706 阅读 · 0 评论 -
生成二叉查找树 中序遍历 输出结果 C++实现
依次输入表(30, 15, 28, 20, 24, 10, 12, 68, 35, 50, 46, 55)中的元素,生成一棵二叉排序数,要求:编程构建一个二叉排序数,并中根遍历验证上述结果。#include <stdio.h> #include <iostream> using namespace std; #define size 20 typedef int Elem...原创 2018-06-27 15:55:29 · 1754 阅读 · 0 评论 -
二叉排序树 插入 删除
#include <stdio.h> #include <iostream> using namespace std; #define size 20 typedef int Elemtype; /*二叉排序树的二叉链表存储结构*/ typedef struct BTNode { Elemtype key; struct BTNode *lchild, *rchil...原创 2018-06-27 21:52:23 · 202 阅读 · 0 评论 -
判断二叉树是否为二叉排序树
编写一个判别给定二叉树是否为二叉排序树的算法,假设二叉树是用左右链方式存储。#include<stdio.h> #include<stdlib.h> #define MIN -256; typedef int TElemType; typedef struct BiTNode { TElemType data; struct BiTNode *lchild, *rch...原创 2018-06-28 10:29:22 · 5130 阅读 · 3 评论 -
数据结构 基础知识整理
一、循环队列 1、头指针front,尾指针rear 当rear > front时,元素个数为rear - front; 当rear <= front时,元素个数为rear-front+capacity; 综上述两种情况,可得元素个数为(rear-front+capacity)%capacity,其中ca...原创 2019-09-25 11:00:13 · 396 阅读 · 0 评论