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