数据结构学习笔记(1)---单向链表
来源:互联网 发布:unity3d游戏开发 pdf 编辑:程序博客网 时间:2024/06/03 23:43
数据结构学习笔记—单向链表
- 链表的初始化
- 头插法创建链表
- 尾插发创建链表
- 链表的显示
- 按索引值查找节点
- 按索引值删除节点
- 按索引值添加节点
(1)链表的初始化
void InitList(pListNode *pHead){ *pHead = new ListNode; (*pHead)->next = NULL;}
(2)头插法创建链表
void HeadCreatList(pListNode pHead){ int date; pListNode pNew = NULL; cout
(3)尾插法创建链表
void TailCreatList(pListNode pHead){ int date; pListNode pTail = NULL; pTail = pHead; cout#####(4)显示链表节点
void ShowList(pListNode pHead){ pListNode p = pHead->next ; while (p) { cout
(5)按索引值查找节点
pListNode FindByIndex(pListNode pHead,int index){ pListNode p = pHead->next; int i = 0; while (p && i
(6)按索引值删除节点
void DeleteByIndex(pListNode pHead, int index){ if (index == 0) { pListNode pNew = pHead->next; pHead->next = pHead->next->next; delete pNew; return; } pListNode pNew = FindByIndex(pHead,index-1); if (!pNew) { return; } pListNode de = pNew->next; pNew->next = pNew->next->next; delete de;}
(7)按索引值添加节点
void AddByIndex(pListNode pHead, int index,int date){ if (0 == index ) { pListNode p = new ListNode; p->date = date; p->next = pHead->next; pHead->next = p; return; } pListNode pNew = FindByIndex(pHead, index-1); if (!pNew) { return; } pListNode p = new ListNode; p->next = NULL; p->date = date; p->next = pNew->next; pNew->next = p;}
对于上面的按索引值相当于数组 ,即第一个存有有效数据的节点的索引值为0,
阅读全文
0 1
- 数据结构学习笔记(1)---单向链表
- 数据结构学习笔记——单向链表
- 数据结构--单向链表1
- 数据结构(单向链表)
- 单向链表学习笔记
- 学习笔记--单向链表
- 数据结构学习系列1-简单单向链表
- [数据结构算法学习] 单向链表
- 数据结构学习之单向链表结构
- 数据结构学习之单向链表结构
- 数据结构-单向链表
- 【数据结构】单向链表
- [数据结构] 单向链表
- 数据结构~~单向链表
- 数据结构单向链表
- 数据结构-单向链表
- 数据结构 单向链表
- 数据结构--单向链表
- 练习1
- numpy
- 关于spark一些参数的问题
- 2017.9.8 页面重构之css中input与button高度不一致的原因及解决方法
- 新路程------hi3516a 在应用层对寄存器的操作
- 数据结构学习笔记(1)---单向链表
- 解释型语言和编译型语言
- Roslyn导致发布网站时报错-编译失败
- 技术文章 | 一篇文章学会spring boot(包括jms和hessian的集成)
- spring的启动过程
- 关于设计模式的自我理解
- 找工作
- Android studio 与 genymotion 的下载链接与安装方法
- 连续特征离散化