随笔分类 -  数据结构

摘要:带头结点的链表和不带头结点的链表之间存在一定的区别1.phead是从第一个开始循环(第一个数据元素), 带头结点的phead从第二个结点开始循环(第一个数据元素)2.不带头结点的链表在插入和删除操作的时候需要把插入的第一个位置和其他位置分开讨论,带头结点的链表在插入和删除的时候操作一致主要原因是不带头结点的链表phead和phead->next赋值的时候不一致的情况造成的。所以带头结点的链表比不带头结点的链表方便所有的操作都是针对元素本身,所以需要找到或者给出元素所在的位置i,才能对其进行操作,插入和删除找到的是i-1若是对整个结构操作,则需要利用循环,同样利用到位置i或者指针p对数据元 阅读全文
posted @ 2013-06-21 22:46 l851654152 阅读(949) 评论(0) 推荐(0)
摘要:1 #include <stdio.h> 2 /*2013-06-19 liuwei*/ 3 typedef int elemtype ; 4 5 #define MAXSIZE 100 6 #define LISTSIZEINCREASE 10 7 #define OK 0 8 #define ERROR -1 9 10 //线性表顺序存储结构描述 11 12 13 typedef struct 14 { 15 elemtype *elem; 16 int length; 17 int listsize; 18 } SqList; 19 ... 阅读全文
posted @ 2013-06-19 16:17 l851654152 阅读(364) 评论(0) 推荐(0)
摘要:View Code 1 #include <stdio.h> 2 #define OK 1 3 int BubbleSort(int *a,int length); 4 int main() 5 { 6 int a[9] = {5,8,7,36,54,21,2,3,19}; 7 BubbleSort(a,9); 8 for(int i = 0;i < 9;i++) 9 {10 printf("%d ",a[i]);11 }12 printf("\n");13 return 0;14 }15 16 int BubbleSo... 阅读全文
posted @ 2012-09-08 14:35 l851654152 阅读(171) 评论(0) 推荐(0)
摘要:View Code 1 #include <stdio.h> 2 #define OK 1 3 int SelectSort(int *a,int length); 4 int main() 5 { 6 int a[8] = {5,7,52,87,64,61,2,38}; 7 SelectSort(a,8); 8 for(int i = 0;i < 8;i++) 9 {10 printf("%d ",a[i]);11 }12 printf("\n");13 return 0;14 }15 16 int SelectSor... 阅读全文
posted @ 2012-09-08 13:33 l851654152 阅读(166) 评论(0) 推荐(0)
摘要:View Code 1 #include <stdio.h> 2 void InsertSort(int *a,int length); 3 int main() 4 { 5 int a[8] = {5,8,7,10,25,64,3,1}; 6 InsertSort(a,8); 7 for(int i = 0;i<8;++i) 8 { 9 printf("%d ",a[i]);10 }11 printf("\n");12 return 0;13 }14 void InsertSort(int *a,int length)... 阅读全文
posted @ 2012-09-07 11:05 l851654152 阅读(176) 评论(0) 推荐(0)
摘要:View Code 1 #include <stdio.h> 2 #include "SqStack.h" 3 #include <stdlib.h> 4 int main() 5 { 6 SqStack s; 7 InitStack(s); 8 int num; 9 int e;10 scanf("%d",&num);11 DtoBcovert(s,num);12 while(!IsEmpty(s))13 {14 Pop(s,e);15 printf("%d",e);16 }17 printf(&qu 阅读全文
posted @ 2012-09-05 23:01 l851654152 阅读(175) 评论(0) 推荐(0)
摘要:STL和数据结构有什么关系呢?STL是以数据结构为模型,将数据结构变成一种数据类型(类),而且标准化,采用泛型编程的思想将类型(类)里面的元素(成员变量)泛型化。数据结构里的树的学习过程,可以结合线性表,树的叶子结点其实可以当做是线性表里的最后一个元素。只是最后一个元素大于等于一个。数据结构要充分考虑逻辑关系。 阅读全文
posted @ 2012-08-31 15:23 l851654152 阅读(385) 评论(0) 推荐(0)
摘要:数据结构 = 数据元素 + 数据关系;数据类型 = 数据结构 + 数据操作;所以数据类型的范畴是大于数据结构的。数据类型的范畴和类有点相似。其实类也是一种数据类型。int,char基本类型 同样可以抽象成数据结构和数据元素的模型,只是这里的数据元素是规定内存分配大小。只要定义了一个变量或者一个对象,这个变量或者对象就应该是有值的,因为内存单元是实实在在存在的,只要有内存单元就会有值,然后我们可以初始化这个变量或者对象,然后对其进行操作。 阅读全文
posted @ 2012-08-19 07:30 l851654152 阅读(3808) 评论(0) 推荐(3)