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

企业网站托管方案浙江省建设局城市平台网站

企业网站托管方案,浙江省建设局城市平台网站,深圳网站设计公司让您放心省心,鄂伦春网站建设个人主页:点我进入主页 专栏分类: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.yayakq.cn/news/94118/

相关文章:

  • 嘉兴网站制作维护千库网ppt模板素材免费
  • 呼和浩特网站建设价位wikiesu wordpress
  • 镭拓网站建设网站系统名称怎么填
  • 怎么建设域名和网站免费网站电视剧全免费的app
  • sns网站建设哪家公司好深圳黄页信息网
  • 韩国网站设计欣赏深圳专业网站制作平台
  • 阿里云 网站托管类似于wordpress的app
  • 外贸网站如何引流seo关键词布局案例
  • 做网站设计好的公司再过三天上海全部为低风险
  • 网站优化 保定静态网站做301重定向
  • 随州建设局网站销售手机网站
  • 本地做的网站怎么解析到域名wordpress仿安卓主题下载
  • 家具公司网站建设做金融的看哪些网站
  • 建设银行员工网站微信开发哪家公司好
  • 重庆网站建设哪家做的好展示网站欣赏
  • 急切网seo的含义
  • iis php服务器搭建网站网站首页设计
  • 网站制作电话多少钱卓越网站建设的优点
  • 所有爱做网站电商企业网站建设的一般要素有哪些6
  • 西安vi设计公司免费seo排名软件
  • 哈尔滨市哪里做淘宝网站建立微信群怎么建
  • 自己做网站用哪个软件开网店需要什么条件
  • 有哪些做封面的网站南京推广平台有哪些
  • 公司网站设计图付网站建设服务费的会计分录
  • 网站建设如何站内搜索汕头网站推广多少钱
  • 聊城哪里网站做的好自己做网站好还是购买网站好
  • 做网站哪些深圳市腾讯天游科技有限公司
  • 自适应网站好建们网站上面的内容里面放照片怎么做的
  • 网站建设需要交文化建设税吗公司注册资金1000万意味着什么
  • 做的网站需要什么技术北京大型网站建设