数据结构
skyfire1123
这个作者很懒,什么都没留下…
展开
-
顺序结构(数组)线性表
#include #define maxn 1000 using namespace std; struct List{ int data[maxn]; int last; }; List *MakeEmpty(); int FindKth(int K,List *list); int Find(int X,List *list); void Insert(int X,int i,Lis原创 2015-12-17 10:00:00 · 199 阅读 · 0 评论 -
链式结构线性表
#include using namespace std; struct Node{ int Data; Node *Next; }; struct List{ Node *head; }; List MakeEmpty(){ List list; list.head=NULL; return list; } int Length(List *list){ Node *p;原创 2015-12-17 10:01:10 · 245 阅读 · 0 评论 -
顺序结构(数组)的堆栈
#include #define maxn 1000 using namespace std; struct Stack{ int Data[maxn]; int Top; }; Stack *CreateStack(){ Stack *PtrS = (Stack*)malloc(sizeof(Stack)); PtrS->Top=-1; return PtrS; } void原创 2015-12-17 10:02:33 · 282 阅读 · 0 评论 -
链式结构的堆栈
#include using namespace std; struct Stack{ int Data; Stack *next; }; Stack *CreateStack(){ Stack *PtrS =(Stack*)malloc(sizeof(Stack)); PtrS->next=NULL; return PtrS; } void Push(Stack *PtrS,i原创 2015-12-17 10:03:17 · 259 阅读 · 0 评论 -
二分查找
#include #define maxn 1000 #define NoFound -1 using namespace std; const int Record[]={5,16,39,45,51,98,100,202,226,321,368,444,501}; struct StaticTable{ int Data[maxn]; int Length; }; StaticTab原创 2015-12-17 20:33:34 · 325 阅读 · 0 评论 -
二叉树的遍历C++实现
strcut BinTree{ ElementType Data; BinTree Left; BinTree Right; } //先序遍历递归法: void PreOrderTraversal(BinTree BT) { if(BT){ coutData; PreOrderTraversal(BT->Left); PreOrderTraversal(BT->Right);转载 2015-12-23 15:41:59 · 291 阅读 · 0 评论