当前位置:网站首页>链表的简单描述及代码的简单实现
链表的简单描述及代码的简单实现
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
边栏推荐
- Data to enhance Mixup principle and code reading
- Advanced Numbers_Review_Chapter 1: Functions, Limits, Continuity
- 2022-08-04:输入:去重数组arr,里面的数只包含0~9。limit,一个数字。 返回:要求比limit小的情况下,能够用arr拼出来的最大数字。 来自字节。
- 常见的硬件延迟
- 基于左序遍历的数据存储实践
- 软链接引发的物理备份问题
- [In-depth study of 4G/5G/6G topic-51]: URLLC-16-"3GPP URLLC related protocols, specifications, and technical principles in-depth interpretation"-11-High reliability technology-2-Link adaptive enhancem
- 用@Mapper查询oracle的分区情况报错
- nodeJs--封装路由
- Unleashing the engine of technological innovation, Intel joins hands with ecological partners to promote the vigorous development of smart retail
猜你喜欢

线性表的查找

Quickly learn chess from zero to one

【LeetCode刷题】-数之和专题(待补充更多题目)

Regular expression to match a certain string in the middle

J9数字货币论:web3的创作者经济是什么?

Ant Sword Advanced Module Development

特殊矩阵的压缩存储

LeetCode uses the minimum cost to climb the stairs----dp problem

Data to enhance Mixup principle and code reading

dmp(dump)转储文件
随机推荐
LeetCode uses the minimum cost to climb the stairs----dp problem
Gantt chart is here, project management artifact, template is used directly
Intel XDC 2022 Wonderful Review: Build an Open Ecosystem and Unleash the Potential of "Infrastructure"
[C language] Detailed explanation of stacks and queues (define, destroy, and data operations)
C student management system Insert the student node at the specified location
leetcode-另一棵树的子树
Cloud Native (32) | Introduction to Platform Storage System in Kubernetes
1527. 患某种疾病的患者
Access Characteristics of Constructor under Inheritance Relationship
select 标签自定义样式
Semi-Decentralized Federated Learning for Cooperative D2D Local Model Aggregation
Error: Not a signal or slot declaration
从零到一快速学会三子棋
select tag custom style
散列表的查找(哈希表)
View handler 踩坑记录
View handler stepping record
[LeetCode Brush Questions] - Sum of Numbers topic (more topics to be added)
lua learning
1527. Patients suffering from a disease