当前位置: 首页 > news >正文

教育培训手机网站模板下载宁波seo网络推广推荐

教育培训手机网站模板下载,宁波seo网络推广推荐,牡丹江做网站建设,邢台口碑好的网站建设个人主页:点我进入主页 专栏分类:C语言初阶 C语言程序设计————KTV C语言小游戏 C语言进阶 C语言刷题 数据结构初阶 欢迎大家点赞,评论,收藏。 一起努力,一起奔赴大厂。 目录 1.前言 2.带头双…

个人主页:点我进入主页

专栏分类:C语言初阶      C语言程序设计————KTV       C语言小游戏     C语言进阶

C语言刷题       数据结构初阶

欢迎大家点赞,评论,收藏。

一起努力,一起奔赴大厂。

目录

1.前言

2.带头双向循环链表函数实现

3.总结


1.前言

        在前面我们写过单链表,循环链表的博客,今天我主要给大家来带关于双向带头循环链表函数的功能与实现,双向带头循环链表相对于单链表,循环链表非常的容易实现,他的函数的功能和 单链表,循环链表一样,如果你想要快速实现一个链表的所有功能,带头双向循环链表非常的容易,接下来让我们看看带头双向链表的奥妙把,看完你绝对会佩服写出这种结构的人。

2.带头双向循环链表函数实现

#include<stdio.h>
#include<stdlib.h>
#include <assert.h>
typedef struct ListNode {int data;struct ListNode* prev, * next;
}ListNode;
ListNode* ListCreate(int x)
{ListNode* newnode = (ListNode*)malloc(sizeof(ListNode));if (newnode == NULL){perror("malloc");return NULL;}newnode->next = NULL;newnode->prev = NULL;newnode->data = x;return newnode;
}
ListNode* LInit()
{ListNode* head = ListCreate(-1);head->next = head;head->prev = head;return head;
}
void ListDestory(ListNode* phead)
{assert(phead);ListNode* cur = phead->next, * prev = phead;while (prev != phead){free(prev);prev = cur;cur = cur->next;}
}
void ListPrint(ListNode* phead)
{assert(phead);ListNode* cur = phead->next;printf("哨兵位<=>");while (cur != phead){printf("%d<=>", cur->data);cur = cur->next;}printf("\n");
}
void ListPushBack(ListNode* phead, int x){assert(phead);ListNode* newnode = ListCreate(x);ListNode* tail = phead->prev;tail->next = newnode;newnode->prev = tail;newnode->next = phead;phead->prev = newnode;
}
void ListPushFrount(ListNode* phead, int x)
{assert(phead);ListNode* newnode = ListCreate(x);ListNode* cur = phead->next;phead->next = newnode;newnode->prev = phead;newnode->next = cur;cur->prev = newnode;
}
void ListPopBack(ListNode* phead)
{assert(phead && phead->next != phead);ListNode* cur = phead->prev;cur->prev->next = phead;phead->prev = cur->prev;free(cur);
}
void ListPopFrount(ListNode* phead)
{assert(phead && phead->next != phead);ListNode* cur = phead->next;phead->next = cur->next;cur->next->prev = phead;free(cur);
}
ListNode* ListFind(ListNode* phead, int x)
{assert(phead);ListNode* cur = phead->next;while (cur->data != x){cur = cur->next;}return cur;
}
void ListInsert(ListNode* pos, int x)
{assert(pos);ListNode* newnode = ListCreate(x);ListNode* cur = pos->prev;cur->next = newnode;newnode->prev = cur;newnode->next = pos;pos->prev = newnode;
}
void ListErase(ListNode* pos)
{assert(pos);ListNode* cur = pos->next;ListNode* prev = pos->prev;free(pos);cur->prev = prev;prev->next = cur;
}
void text1()
{ListNode* head = LInit();ListPushBack(head, 1);ListPushBack(head, 2);ListPushBack(head, 3);ListPushBack(head, 4);ListPushBack(head, 5);ListPushFrount(head, 0);ListPrint(head);ListPopBack(head);ListPrint(head);ListPopBack(head);ListPrint(head);ListPopFrount(head);ListPrint(head);ListPopFrount(head);ListPrint(head);ListPushBack(head, 4);ListPushBack(head, 5);ListNode* cur = ListFind(head,3);ListPushFrount(head, 1);ListPushFrount(head, 0);	printf("%d\n", cur->data);ListPrint(head);ListInsert(head, 10);ListPrint(head);
}

3.总结

        带头双向循环的链表非常的好,接下俩我们对顺序表和链表的存储空间,随机访问,任意位置插入或删除元素,插入,缓存利用率,应用场景进行分析

不同点顺序表链表
存储空间上物理上一定连续逻辑上连续,但物理上不一定连
随机访问支持O(1)不支持:O(N)
任意位置插入或者删除元
可能需要搬移元素,效率低O(N)只需修改指针指向
插入动态顺序表,空间不够时需要扩
没有容量的概念
应用场景元素高效存储+频繁访问任意位置插入和删除频繁
缓存利用率

http://www.hkea.cn/news/312983/

相关文章:

  • 网站链接太多怎么做网站地图谷歌广告
  • 网站关键词更新临汾网络推广
  • 个人做网站靠什么盈利免费网站建设模板
  • 网站开发 打标签aso优化怎么做
  • 教育校园网站建设方案seo每天一贴
  • 怎么看网站的建设时间推广公司品牌
  • 营销型网站有什么特点英语培训机构
  • 学院网站的系统建设方式宝鸡网站seo
  • 网站客户端怎么做的百度一下了你就知道官网
  • 有什么推广方法优化大师电脑版官方
  • 自己做网站的服务器上海网站建设公司排名
  • 跳蛋塞逼做多的视频网站百度广告联盟官网
  • 房地产网站开发文档企业查询
  • 做emu对网站有什么要求十大免费无代码开发软件
  • 扬州专业做网站做关键词优化
  • 宿州网站建设贰聚思诚信网站服务器
  • 用照片做模板下载网站好百度爱采购官方网站
  • 微网站建设套餐网络营销是做什么的
  • 徐州有哪些做网站苏州网站建设费用
  • 统一企业信息管理系统网站直通车怎么开效果最佳
  • 武汉外贸网站建设公司外链相册
  • java做网站的权限管理seo描述是什么
  • 招聘网最新招聘信息网武汉seo计费管理
  • 直播软件开发源码重庆seo顾问
  • 公司网站如何做宣传百度视频推广怎么收费
  • 淄博市 网站建设报价郑州seo外包阿亮
  • 网络服务商是指什么网站优化排名工具
  • 网站优化的分析比较好的品牌策划公司有哪些
  • 国外比较好的资源网站电商运营推广是做什么的
  • 佛山房地产网站建设seo实战培训王乃用