Richard Liu’s Blog
首页
搜索
友情链接
往期整理
  •   历史归档
  •   文章分类
  •   文章标签
关于我
Richard Liu
Article
19
Category
4
Tags
8
首页
搜索
友情链接
往期整理
历史归档
文章分类
文章标签
关于我
链表(Linklist)
Post on:
Last edited: 2024-12-30
Views

单链表

结点

结点定义

C
C++
💡
n每个结点只包含一个指针域的链表称为单链表
n单链表可由头指针惟一确定
n单链表最后一个元素的指针域为空(NULL)
n为了操作方便,有时在线性链表的第一个结点之前附设一个头结点,其数据域可以为空,也可以为线性链表的长度信息。
notion image

带头结点的单链表定义

查找

按值查找

按位置查找

💡
链表位置从1开始计算

插入

notion image
 
notion image
s->next = p->next; p->next = s;
时间复杂度

删除

notion image
notion image
p->next = p->next ->next
时间复杂度为

合并

notion image
notion image
保持递增有序
时间复杂度为
 
Loading...
Richard Liu
Richard Liu
Richard Liu
Article
19
Category
4
Tags
8
小红书
Latest posts
Cherry Studio自用CSS
Cherry Studio自用CSS
2025-5-23
浙B印象
浙B印象
2025-5-23
大雾实验
大雾实验
2025-5-21
Kanon 雪之少女
Kanon 雪之少女
2025-5-20
20241019仙湖植物园小柔
20241019仙湖植物园小柔
2025-4-6
34th萤火虫漫展
34th萤火虫漫展
2025-4-6
Announcement
新年快乐喵~
 
 
2024-2025 Richard Liu.

Richard Liu’s Blog | Richard Liu

Powered by NotionNext 4.7.5.