当前位置:网站首页>链表的简单描述及代码的简单实现
链表的简单描述及代码的简单实现
2022-08-05 02:33:00 【小奔同学】
3.链表
3.1 链表的概念及结构
概念:链表是一种物理存储结构上非连续、非顺序的存储结构,数据元素的逻辑顺序是通过链表中的指针链接次序实现的 ,就像下面的火车一样。
现实的数据结构中
注意:
- 链表中结点逻辑上是连续的,在物理上是不一定连续的
- 现实中的结点一般都是由堆申请过来的
- 从堆申请来的空间是按一定的策略来分配的,物理上可能连续,也可能不连续
3.2 链表的分类
实际中链表的结构非常多样,以下情况组合起来就有8种链表结构:
单向或者双向
带头或者不带头
循环或者非循环
虽然有这么多的链表的结构,但是我们实际中最常用还是两种结构:
无头单向非循环链表:结构简单,一般不会单独用来存数据。实际中更多是作为其他数据结构的子结构,如哈希桶、图的邻接表等等。
带头双向循环链表:结构最复杂,一般用在单独存储数据。实际中使用的链表数据结构,都是带头双向循环链表。另外这个结构虽然结构复杂,但是使用代码实现以后会发现结构会带来很多优势,实现反而简单了,下一篇代码实现了就知道了。
3.3 链表的实现
typedef int SLTDateType;
typedef struct SLT
{
SLTDateType data;
struct SLT* next;
}SListNode;
// 动态申请一个节点
SListNode* BuySListNode(SLTDateType x);
// 单链表打印
void SListPrint(SListNode* plist);
// 单链表尾插
void SListPushBack(SListNode** pplist, SLTDateType x);
// 单链表的头插
void SListPushFront(SListNode** pplist, SLTDateType x);
// 单链表的尾删
void SListPopBack(SListNode** pplist);
// 单链表头删
void SListPopFront(SListNode** pplist);
// 单链表查找
SListNode* SListFind(SListNode* plist, SLTDateType x);
// 单链表在pos位置之后插入x
// 分析思考为什么不在pos位置之前插入?
void SListInsertAfter(SListNode* pos, SLTDateType x);
// 单链表删除pos位置之后的值
// 分析思考为什么不删除pos位置?
void SListEraseAfter(SListNode* pos);
// 单链表的销毁
void SListDestroy(SListNode* plist);
// 单链表删除pos位置的值
void SListErase(SListNode** plist, SListNode* pos);
函数具体内容上传到了gitee
边栏推荐
- Go 微服务开发框架 DMicro 的设计思路
- 如何逐步执行数据风险评估
- 特殊矩阵的压缩存储
- post-study program
- Optimizing the feed flow encountered obstacles, who helped Baidu break the "memory wall"?
- [ROS](10)ROS通信 —— 服务(Service)通信
- Industry case | insurance companies of the world's top 500 construction standards can be used to drive the business analysis system
- 2022-08-04: Input: deduplicated array arr, the numbers in it only contain 0~9.limit, a number.Return: The maximum number that can be spelled out with arr if the requirement is smaller than limit.from
- 【C语言】详解栈和队列(定义、销毁、数据的操作)
- DAY22:sqli-labs 靶场通关wp(Less01~~Less20)
猜你喜欢
DAY23: Command Execution & Code Execution Vulnerability
QT语言文件制作
蚁剑高级模块开发
甘特图来啦,项目管理神器,模板直接用
OpenGL 工作原理
nodeJs--封装路由
Quickly learn chess from zero to one
The design idea of DMicro, the Go microservice development framework
[C language] Detailed explanation of stacks and queues (define, destroy, and data operations)
云原生(三十二) | Kubernetes篇之平台存储系统介绍
随机推荐
2022了你还不会『低代码』?数据科学也能玩转Low-Code啦!
线性表的查找
627. 变更性别
Regular expression to match a certain string in the middle
mysql树状结构查询问题
Images using redis cache Linux master-slave synchronization server hard drive full of moved to the new directory which points to be modified
22-07-31周总结
Pisanix v0.2.0 发布|新增动态读写分离支持
Data to enhance Mixup principle and code reading
树表的查找
软链接引发的物理备份问题
C language implements a simple number guessing game
Quickly learn chess from zero to one
RAID disk array
Industry case | insurance companies of the world's top 500 construction standards can be used to drive the business analysis system
Introduction to SDC
解决connect: The requested address is not valid in its context
QT MV\MVC结构
Hypervisor related knowledge points
后期学习计划