当前位置:网站首页>Single step analysis of double linked list insertion and deletion (14)
Single step analysis of double linked list insertion and deletion (14)
2022-04-21 23:00:00 【Burn slowly】
1. Double linked list definition
Single linked list can only operate backward , Cannot move forward . Double linked list can operate forward and backward .
Double linked list features : The following figure explains
A precursor pointer :ai The forerunner of , Point to ai-1 node , Storage ai-1 The address of .
Data fields : Storing data
A rear drive pointer :ai Rear drive pointer , Point to ai+1 node , Storage ai+1 The address of .
The above concepts are the key to understanding the two-way linked list .

2. The insert
In the i In front of a node , Insert a e node .

analysis :
<1>.p->prior->next = s;
p: To point to ai A pointer to a node
p->prior: Means to store ai-1 The address of the node .
p->prior->next: Means to store ai-1 The trailing pointer of the address of the node , Not inserted e Before node , It's pointing ai Nodal , But now let it point to e The address of the node ( The pointer s).
translate : take ai-1 The node's back drive pointer points to s, Save s The address of the node .
<2>.s->prior = p->prior;
s: Point to the... To insert e A pointer to a node , namely e The address of the node .
s->prior:e node address s The forerunner of , Store the address of the previous node .
p: To point to ai A pointer to a node , namely ai The address of the node .
p->prior: Means to store ai-1 The address of the node .
translate :s The precursor pointer of the node points to ai-1 The address of .
<3>.s->next = p;
s: Point to the... To insert e A pointer to a node , namely e The address of the node .
s->next:s The trailing pointer of the node ;
p: To point to ai A pointer to a node , namely ai The address of the node .
translate :s The trailing pointer of the node points to p node , namely s The back drive pointer of the node is saved ai The address of the node .
<4>.p->prior = s;
p: To point to ai A pointer to a node , namely ai The address of the node .
p->prior: Means to store ai-1 The address of the node .
s: Point to the... To insert e A pointer to a node , namely e The address of the node .
translate : Point to ai Nodal p The precursor of the pointer points to e node , namely ai The node precursor pointer is saved s The address of the node .
thus , take e The node is inserted in ai-1 and ai Between nodes .
3. Delete operation
Delete ai node .

analysis :
<1>.p->prior->next = p->next;
p: Point to ai A pointer to a node .
p->prior:ai The precursor pointer of the node , Save the ai-1 The address of the node .
p->prior->next:ai-1 The subsequent pointer field of the node , Actually store ai The address of the node .
p->next:ai The subsequent pointer of the node , Stored ai+1 The address of the node .
translate : take ai-1 The subsequent pointer of the node points to ai The subsequent pointer of the node , because ai The subsequent pointers of the store ai+1 The address of , In fact, that is ai-1 The back pointer of the node points to ai+1 The address of the node , Save ai+1 The address of the node , Skip the ai node .
<2>.p->next->prior = p->prior;
p: Point to ai A pointer to a node .
p->next:ai The subsequent pointer of the node , preserved ai+1 The address of the node .
p->next->prior:ai+1 The precursor pointer of the node , preserved ai The address of the node .
p->prior:ai The precursor pointer of the node , Save the ai-1 The address of the node .
translate : take ai+1 The precursor pointer of the node , Point to ai-1 The address of the node .
thus , Is deleted ai node .
版权声明
本文为[Burn slowly]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204212023276874.html
边栏推荐
- VOS6. 0 installation and source code command
- 循环队列与扩容
- 当贝X3色彩对比度好不好,新3.1版本色彩接近原图
- 【matlab中一些小技巧和快捷键使用总结】
- [RL] deeply understand the use of gradient descent in tabular learning (MC / TD)
- VOS7. 03 installation and source code command
- Basic concepts of audio and video and a simple introduction to ffmpeg
- 方法的重载
- Apache Flink系列-④有状态函数
- 自建vnc类软件注意事项
猜你喜欢

当贝X3色彩对比度好不好,新3.1版本色彩接近原图

模块三:外包学生管理系统-架构设计文档

大厂面经合集,这些知识点你会吗

Chapter 2 installation of MySQL database
![[basic learning of FPGA ------ ov7725 camera module]](/img/74/71ead5bca4619456841ce3a4c95b65.png)
[basic learning of FPGA ------ ov7725 camera module]

2022 hoisting machinery command test question simulation test question bank and answers

MySQL multi table query exercise

REM practical development adaptation scheme for mobile web development

Nacos Registry - service registration and tiered storage

Apache Flink系列-④有状态函数
随机推荐
Implementation of neural network attention mechanism by pytoch code
Oracle database 22c insight:_ kgl_ Large_ heap_ assert_ Threshold automatic and manual adjustment
Redis advanced: data deletion and elimination strategy, master-slave replication, sentinel mode, cluster, enterprise solution
查询哪些表有唯一索引(除了主键)
Informatics Aosai yibentong 1210: factor decomposition | openjudge 1.13 22: factor decomposition
Is it safe to open futures account on mobile phone? Do you need to handle it offline?
[basic learning of FPGA ------ ov7725 camera module]
8.3 create a mobile robot by hand in rodf robot modeling
Apache Flink series - ④ stateful functions
MySQL 第5章 MySQL表数据的增删改查
Kubenetes(3)--网络通信(2)--flannel和calico
Analysis on the underlying principle of MySQL transaction and isolation level
Go language self-study series | golang defer statements
Wiki. JS configure LDAP authentication
Deploying wikijs using Helm
Comparison between member variables and local variables
2022 electrician (elementary) examination simulated 100 questions and simulated examination
VOS7.03安装及源码命令
YARN线上动态资源调优
将模型训练外包真的安全吗?新研究:外包商可能植入后门,控制银行放款