数据结构
文章平均质量分 70
岳麓丹枫2013
这个作者很懒,什么都没留下…
展开
-
数据结构_链队列相关操作
#include#includetypedef struct Node{ int data; struct Node *next;}Node;typedef struct{ Node * front; Node * rear;}Queue;void InitQueue(Queue原创 2014-07-15 22:34:57 · 417 阅读 · 0 评论 -
数据结构_两个有序链表归并成新的链表(基于头插法建表与尾插法建表)
void MergeListR(LNode *A,LNode *B,LNode* &C)//采用尾插法建表的链表归并 算法 (A,B为递增链表,C要求为单调不减链表){ LNode *r=NULL; LNode *p=A->next; LNode *q=B->next; C=A; C->next=NULL; r=C;原创 2014-07-09 23:21:14 · 1193 阅读 · 0 评论 -
数据结构_动态数组形式的顺序表相关操作C语言源代码
#include#includetypedef struct { int *data; int length;}Sqlist;void test_Addr(Sqlist L){ printf("addr of L is :%p\n",&L.data); printf("addr of L is :%d\原创 2014-07-08 23:21:39 · 479 阅读 · 0 评论 -
数据结构_顺序栈相关操作
#include#includeusing namespace std;const int maxSize=100;typedef struct { int data[maxSize]; int top;}Stack;void InitStack(Stack &S){ S.top = -1;}原创 2014-10-06 21:57:36 · 399 阅读 · 0 评论 -
数据结构_栈的相关操作
#includeusing namespace std;#includetypedef int ElemType;typedef struct LNode{ ElemType data; struct LNode *next;}LNode;void InitStack(LNode *&S)//初始化 {原创 2014-10-06 12:02:10 · 370 阅读 · 0 评论 -
数据结构_循环队列
#include#includeusing namespace std;const int maxSize = 50;typedef struct { int data[maxSize]; int front; int rear;}Queue;void InitQueue(Queue &Q)//初始化顺序队列原创 2014-10-07 22:38:23 · 412 阅读 · 0 评论 -
数据结构_顺序表
#include#include#define maxSize 100typedef struct { int data[maxSize]; int length;}SqList;void InitList(SqList &L){ L.length = 0;}int ListInsert(SqList &L原创 2014-09-29 23:07:19 · 441 阅读 · 0 评论 -
数据结构_链队列相关操作
#includeusing namespace std;typedef struct Node{int data;struct Node *next;}Node;typedef struct {Node *front;Node *rear;}Queue;void InitQueue(Queue &Q){Node *p原创 2014-10-08 10:59:35 · 422 阅读 · 0 评论 -
数据结构_单链表
#include#include#includeusing namespace std;typedef struct LNode{ int data; LNode *next;}LNode;void InitList(LNode *&L)//初始化 { L=new LNode; L->data =原创 2014-10-01 15:20:07 · 363 阅读 · 0 评论 -
数据结构_顺序表相关操作C语言源代码
#include#includeconst int MAXSIZE=100;typedef struct { int data[MAXSIZE]; int length; }Sqlist;void InitList(Sqlist &L)//顺序表初始化 { L.le原创 2014-07-07 22:53:45 · 471 阅读 · 0 评论 -
数据结构_双链表的建立及相关操作
#include#includetypedef struct DLNode{ int data; struct DLNode *prior; struct DLNode *next;}DLNode;void InitDList(DLNode *&L) { L=(DLNode*)malloc(sizeof(DLNode)原创 2014-07-10 12:01:45 · 414 阅读 · 0 评论 -
数据结构_递归算法的应用_打印n个数的全排列数
#include#includevoid Swap(int &a, int &b) { int t=a; a=b; b=t; }void f(int a[], int k, int n){ int i; if(k==0) { for(i=0;i原创 2014-07-17 22:28:23 · 673 阅读 · 0 评论 -
数据结构_栈的应用_十进制转化为二进制
#include#includeconst int M=100;int Digital_To_Binary(int N){ int i,result=0; int stack[M],top=-1;//栈的定义与初始化 while(N!=0) { stack[++top]=N%2;原创 2014-07-16 22:13:47 · 1687 阅读 · 0 评论 -
数据结构_二叉树的先序建立与先序,中序,后序(递归)遍历方式_C语言源代码
#include#includetypedef struct BTNode{ char data; struct BTNode * lchild; struct BTNode * rchild;}BTNode;void CreateBTree(BTNode *&T){ char ch; s原创 2014-07-20 12:16:16 · 1595 阅读 · 0 评论 -
数据结构_求二叉树的高度以及层次遍历二叉树算法_C语言源代码
int Height(BTNode *T)//求二叉树高度{ int L,R; if(NULL == T) return 0; else { L=Height(T->lchild); R=Height(T->rchild); return L>R ? L+1 :R+1;原创 2014-07-20 12:41:17 · 3359 阅读 · 2 评论 -
数据结构_查找二叉树中值为key的节点,并将指针指向该节点_C语言源代码
void PreSearch(BTNode *T, BTNode *&p,char key)//x先序方式查找二叉树中,值为key的节点,并将指针p指向该节点 { if(NULL != T) { if(T->data == key) { p=T; return ;原创 2014-07-20 13:12:29 · 2632 阅读 · 1 评论 -
数据结构_输出二叉树中先序、中序、后序遍历方式中第k个节点的数据
//输出先序遍历中第k个节点的值int n =0;void Travel(BTNode *T, int k){ if(NULL != T) { if(++n == k) { printf("第%d个节点的数据为:%c\n",k,T->data);原创 2014-07-20 14:20:10 · 3375 阅读 · 0 评论 -
数据结构_求二叉树中度为0,为1,为2的节点的个数以及所有节点个数
int NumberOfZeroDegree(BTNode *T)//求二叉树中度为1的节点个数 { int i=0; if(NULL != T) { if(NULL==T->lchild && NULL==T->rchild) { i=1;原创 2014-07-20 15:05:05 · 15084 阅读 · 0 评论 -
数据结构_求二叉树的宽度_C语言源代码
typedef struct { BTNode *p; int line;}PL;const int M=50;int BTreeWidth(BTNode *T) { BTNode *s; int LNO; PL Q[M]; int front=0,rear=0; int i,j;原创 2014-07-20 16:34:24 · 3182 阅读 · 0 评论 -
数据结构_顺序表
//#include#include#include#includeusing namespace std;const int maxSize=100;typedef struct { int data[maxSize]; int length;}SqList;void InitList(SqList &L);原创 2014-10-01 14:36:35 · 383 阅读 · 0 评论