随笔分类 -  数据结构

摘要:时间复杂度 1. 算法复杂度分为 时间复杂度和空间复杂度。 作用: 时间复杂度是度量算法执行的时间长短;而空间复杂度是度量算法所需存储空间的大小。 2. 一般情况下,算法的基本操作重复执行的次数是模块n的某一个函数f(n),因此,算法的时间复杂度记做:T(n)=O(f(n)) 分析:随着模块n的增大,算法执行的时间的增长率和f(n)的增长率成正比,所以f(n)越小,算法的时间复杂度越低,算法的效率越高。 3. 在计算时间复杂度的时候,先找出算法的基本操作,然后根据相应的各语句确定它的执行次数,在找出T(n)的同数量级(它的同数量级有以下:1,Log2n ,n ,nLog2n ,n的平... 阅读全文
posted @ 2009-07-30 08:14 Roader 阅读(248) 评论(0) 推荐(1)
摘要:#include#include#define NULL 0#define LEN sizeof(struct student)struct student{long num;float score;struct student * next;};int n;struct student * creat(void){struct student * head;struct student *p1,*p2;n=0;p1=p2=(struct student *)malloc(LEN);scanf("%ld,%f",&p1->num,&p1->sco 阅读全文
posted @ 2009-07-24 16:34 Roader 阅读(271) 评论(0) 推荐(0)