摘要: 循环单/双链表,创建、初始化、尾插、头插、遍历、插入、删除、判空 部分函数采用重载(此处为c++代码) #include <iostream> #include <stdlib.h> #include <stdbool.h> using namespace std; typedef struct l 阅读全文
posted @ 2020-08-16 12:36 Cool-baby 阅读(20) 评论(0) 推荐(0) 编辑
摘要: 初始化,尾插(头插类似,相当于前一位的尾插),遍历,插入,删除,判空 #include <iostream> #include <stdlib.h> using namespace std; typedef struct dnode{ //定义数据类型 int data; struct dnode 阅读全文
posted @ 2020-08-16 12:34 Cool-baby 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 初始化、头插、尾插、求长度、遍历、插入、删除、按值查找、按位查找 #include <iostream> #include <stdlib.h> using namespace std; typedef struct lnode{ int data; struct lnode *next; }lno 阅读全文
posted @ 2020-08-16 12:33 Cool-baby 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 带头节点尾插/头插 #include <iostream> #include <stdlib.h> using namespace std; typedef struct lnode{ int data; struct lnode *next; }lnode,*linklist; bool init 阅读全文
posted @ 2020-08-16 12:32 Cool-baby 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 无头节点,注意是P=L,不是P=L->next #include <iostream> #include <stdlib.h> #define TRUE 1 #define FALSE 0 using namespace std; typedef struct lnode{ int data; st 阅读全文
posted @ 2020-08-16 12:30 Cool-baby 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 在单链表中的第i个位置上插入制定元素e #include <iostream> #include<stdlib.h> #define TRUE 1 #define FALSE 0 using namespace std; typedef struct lnode{ int data; struct 阅读全文
posted @ 2020-08-16 12:29 Cool-baby 阅读(104) 评论(0) 推荐(0) 编辑
摘要: 按值查找是在顺序表L中查找第一个元素等于e的元素,并返回其位序。 时间复杂度O(n)。 按位查找是在顺序表中查找位序为i的元素,并返回e。 时间复杂度O(1)。 #include <iostream> #include<stdlib.h> #define initsize 10 using name 阅读全文
posted @ 2020-08-16 12:28 Cool-baby 阅读(67) 评论(0) 推荐(0) 编辑
摘要: 静态分配,数组大小和空间已经固定,一旦占满,再插入就会产生溢出。 #include <iostream> using namespace std; #define max 10 typedef struct{ int data[max]; int length; }sqlist; void init 阅读全文
posted @ 2020-08-16 12:26 Cool-baby 阅读(30) 评论(0) 推荐(0) 编辑
摘要: 插入操作—在顺序表L的第i(1<=i<=L.length+1)个位置插入新元素e。 时间复杂的为O(n)。 删除操作—删除顺序表L的第i(1<=I<=l.length)个位置的元素,并返回true。 时间复杂度为O(n)。 #include <iostream> #include<stdlib.h> 阅读全文
posted @ 2020-08-16 12:25 Cool-baby 阅读(45) 评论(0) 推荐(0) 编辑
摘要: 存储空间是程序执行过程中通过动态存储语句分配的,一旦空间占满,就另外开辟一块更大的存储空间,用以替换原来的存储空间。 c语言调用stdlib库,使用malloc,free函数。 c++使用new,delect。 #include<stdlib.h> #include <iostream> #defi 阅读全文
posted @ 2020-08-16 12:22 Cool-baby 阅读(42) 评论(0) 推荐(0) 编辑