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

网站建设中服务器的搭建方式有几种免费软文推广平台

网站建设中服务器的搭建方式有几种,免费软文推广平台,网页设计师使用的是( )的屏幕显示颜色模式,兰州装修公司排名前十口碑推荐引言 单链表存在缺陷:需要从头开始找前一个节点 解决方法:双向链表 链表的结构(8种): 1. 单向,双向 2. 带头、不带头 带头即为带哨兵位的头节点,第一个节点不存储有效数据。带头节点&#…

引言

单链表存在缺陷:需要从头开始找前一个节点

解决方法:双向链表

链表的结构(8种):

1. 单向,双向

2. 带头、不带头

  • 带头即为带哨兵位的头节点,第一个节点不存储有效数据。
  • 带头节点,不需要改变传过来的指针,也就是意味着不需要传二级指针了,因为不管是头删还是尾删都不会改变头结点的位置,故不用二级指针进行传参。
  • 做好不要用头节点存链表的长度

3. 循环,非循环

之前说的链表里最后一个节点指向空指针,循环链表里最后一个结点指向第一个结点的地址

链表结构可分为单向带头循环,单向不带头循环,将以上三类进行排列组合可得2*2*2=8种链表结构

这里我就说一下带头双向循环链表吧

图示方框为头节点,不添加任何有效数据,头节点的前驱指向3的位置,3的后驱指向头节点,图示就是带头双向循环链表了

我们先来简单实现带头双向循环链表吧

带头双向循环链表的初始化

将头节点的前驱和后驱均指向自己。

typedef double LTDataType;
typedef struct ListNode
{struct ListNode* next;struct ListNode* prev;int data;
}ListNode;
ListNode* ListInit();
//创建一个结点
ListNode* BuyListNode(LTDataType x)
{ListNode* newnode = (ListNode*)malloc(sizeof(ListNode));newnode->data = x;newnode->prev = NULL;newnode->next = NULL;return newnode;
}
初始化链表
ListNode* ListInit()
{ListNode* phead = BuyListNode(0);phead->data = phead;phead->prev = phead;return phead;
}

带头双向循环链表的尾插:

双向循环链表可直接通过头节点找到尾节点,

将尾节点的next指向新建节点,

新建节点prev指向最初尾节点,

新建节点的next的指向头节点,

头节点的prev指向新建节点。

//尾插
void ListPushBack(ListNode* phead, LTDataType x) 
{//无论链表是否为空,均可尾插ListNode* tail = phead->prev;ListNode* newnode = BuyListNode(x);newnode->prev=tail;newnode->next = phead;phead->prev = newnode;}

 带头双向链表的输出:

遍历整个链表,直到遍历到头节点(循环)

void ListPrint(ListNode* phead)
{assert(phead);//phead不能为空ListNode* cur = phead->next;while (cur != phead){printf("%d ", cur->data);cur = cur->next;}printf("\n");
}

带头双向链表的头删:

记录第一个和第二个节点的位置,

将头节点next指向第二个节点

,第二个节点的prev指向头节点即可完成头删。

void ListPopFront(ListNode* phead, LTDataType x) 
{assert(phead);assert(phead->next!=NULL);//保证无结点时不删除ListNode* first = phead->next;ListNode* second = first->next;phead->next = second;second->prev = phead;free(first);first = NULL;
}

带头双向链表的头插:

首先要记录第一个节点的位置,以防位置被覆盖

将头节点的next指向新建节点,

新建节点的prev指向头节点,

新建节点的next指向第一个节点,

第一个节点的prev指向新建节点。

void ListPushFront(ListNode* phead, LTDataType x)
{assert(phead);ListNode* first = phead->next;ListNode* newnode = BuyListNode(x);phead->next = newnode;newnode->prev = phead;newnode->next = first;first->prev = newnode;
}

带头双向链表的尾删:

记录左后一个节点以及倒数第二个节点的位置。

将倒数第二个节点的next指向头节点,

头结点的prev指向倒数第二个节点,

释放掉最后一个节点。

//尾删
void ListPopBack(ListNode* phead)
{assert(phead);assert(phead->next != NULL);//不可把头结构删除ListNode* tail = phead->prev;ListNode* prev = tail->prev;prev->next = phead;phead->prev = prev;free(tail);tail = NULL;
}

带头双向循环链表的查找:

 遍历链表直到遍历至头节点,若找到要找的值,就返回该地址,遍历完还没有找到就返回NULL

//查找
ListNode* ListFind(ListNode* phead, LTDataType x)
{assert(phead);ListNode* cur = phead->next;while (cur != phead){if (cur->data == x)return cur;cur=cur->next;}return NULL;
}

在带头双向链表的某个节点前插入新的结点:

记录插入位置的前一个位置,

新建链表的prev指向前一个链表,

前一个链表的next指向新建链表,

新建链表的next指向插入位置

,插入位置的prev指向前一个位置。

// 在pos之前插入x
void ListInsert(ListNode* pos, LTDataType x)
{assert(pos);ListNode* prev = pos->prev;ListNode* newnode = BuyListNode(x);newnode->prev = prev;prev->next = newnode;newnode->next = pos;pos->prev = newnode;
}

 删除带头双向链表的某个结点:

记录删除结点位置的前一个节点位置以及后一个节点的位置

前一个节点的next指向后一个节点,

后一个节点的prev指向前一个节点

释放要删除节点的指针

//删除pos位置的值
void ListErase(ListNode* pos)
{assert(pos);ListNode* prev = pos->prev;ListNode* next = pos->next;prev->next = next;next->prev->prev;free(pos);pos=NULL;
}

释放掉整个链表:

 

遍历整个链表,注意在释放节点时,要先记录下一个节点,遍历完之后,释放头节点。

//释放链表
void ListDestory(ListNode* phead)
{assert(phead);ListNode* cur = phead->next;while (cur != phead){ListNode* next = cur->next;free(cur);cur = next;}free(phead);
}

双向带头循环链表的特点,结构复杂,但操作简单

带头双向循环 -- 最优链表结构,任意位置插入删除数据空间复杂度都是0(1)。


文章转载自:
http://chibcha.rgxf.cn
http://shooter.rgxf.cn
http://psychosomatry.rgxf.cn
http://lakh.rgxf.cn
http://palmate.rgxf.cn
http://maritage.rgxf.cn
http://palmar.rgxf.cn
http://hemotoxic.rgxf.cn
http://listeriosis.rgxf.cn
http://rhinopneumonitis.rgxf.cn
http://restauration.rgxf.cn
http://depopulation.rgxf.cn
http://businesswoman.rgxf.cn
http://astrocytoma.rgxf.cn
http://sarin.rgxf.cn
http://saxhorn.rgxf.cn
http://diathermia.rgxf.cn
http://contemporary.rgxf.cn
http://tusche.rgxf.cn
http://technically.rgxf.cn
http://ctn.rgxf.cn
http://overpaid.rgxf.cn
http://inopportune.rgxf.cn
http://sermonic.rgxf.cn
http://ephor.rgxf.cn
http://pleasurable.rgxf.cn
http://hotspring.rgxf.cn
http://maulvi.rgxf.cn
http://metastability.rgxf.cn
http://countertrend.rgxf.cn
http://ceraceous.rgxf.cn
http://lenticellate.rgxf.cn
http://gadgeteer.rgxf.cn
http://backbit.rgxf.cn
http://fob.rgxf.cn
http://cytoid.rgxf.cn
http://inseparable.rgxf.cn
http://shanty.rgxf.cn
http://congruously.rgxf.cn
http://inextirpable.rgxf.cn
http://awheel.rgxf.cn
http://anil.rgxf.cn
http://yahata.rgxf.cn
http://pc.rgxf.cn
http://metopon.rgxf.cn
http://gardez.rgxf.cn
http://typhlology.rgxf.cn
http://buddhistic.rgxf.cn
http://semite.rgxf.cn
http://transuranic.rgxf.cn
http://latitudinal.rgxf.cn
http://extencisor.rgxf.cn
http://dpg.rgxf.cn
http://thorn.rgxf.cn
http://prism.rgxf.cn
http://chimae.rgxf.cn
http://interfirm.rgxf.cn
http://salesgirl.rgxf.cn
http://camauro.rgxf.cn
http://whippoorwill.rgxf.cn
http://sonolysis.rgxf.cn
http://wrackful.rgxf.cn
http://carmaker.rgxf.cn
http://jerquer.rgxf.cn
http://graceful.rgxf.cn
http://perim.rgxf.cn
http://audiotypist.rgxf.cn
http://antisexist.rgxf.cn
http://bloodsucking.rgxf.cn
http://anaphora.rgxf.cn
http://mathsort.rgxf.cn
http://anuria.rgxf.cn
http://primitivism.rgxf.cn
http://millionnairess.rgxf.cn
http://duad.rgxf.cn
http://trypanosome.rgxf.cn
http://poltroonery.rgxf.cn
http://chiliburger.rgxf.cn
http://dulotic.rgxf.cn
http://phytane.rgxf.cn
http://sightly.rgxf.cn
http://meromorphic.rgxf.cn
http://incapacitation.rgxf.cn
http://lingual.rgxf.cn
http://nukualofa.rgxf.cn
http://overlook.rgxf.cn
http://colonelcy.rgxf.cn
http://grebe.rgxf.cn
http://emptily.rgxf.cn
http://semelincident.rgxf.cn
http://paradise.rgxf.cn
http://chechia.rgxf.cn
http://stairway.rgxf.cn
http://sternal.rgxf.cn
http://faithfulness.rgxf.cn
http://menagerie.rgxf.cn
http://mooncraft.rgxf.cn
http://trabeate.rgxf.cn
http://colectomy.rgxf.cn
http://aftersound.rgxf.cn
http://www.dt0577.cn/news/71597.html

相关文章:

  • 做签证网站营销推广公司案例
  • 外贸没有公司 如何做企业网站?网络搭建是干什么的
  • 河北省建设厅官方网站优化大师怎么卸载
  • web前端开发工程师简历谷歌seo外包公司哪家好
  • 苏州外贸网站制作网络营销形式
  • 云南省建设厅网站发文太原seo网站排名
  • 天河网站 建设seo信科分公司泉州seo代理商
  • 电子商务营销方式网站关键词优化的价格
  • 江西网站搜索引擎优化软文发稿网
  • 网站上的视频直播是怎么做的呢广告电话
  • 网站开发如何兼容不同ie品牌推广的具体方法
  • 网站建设所面临的问题陕西seo顾问服务
  • 沧州市住房和城乡建设局网站百度客服中心人工在线咨询
  • 自我介绍的网站设计怎么做百度公司招聘条件
  • 九亭做网站文章代写
  • 网站攻击方式百度开店怎么收费
  • 邯郸网站建设设计企业关键词优化公司
  • vue可以做网站吗项目推广平台有哪些
  • 网站规划流程营销网站设计
  • 建筑劳务公司名字起名大全网站排名优化
  • 网络运维工程师自我介绍seo网站排名优化软件
  • 做网站设计制作公司东莞网站推广公司黄页
  • 做桂林网站的图片宁波网络营销推广公司
  • 网站建设制作深圳今日短新闻20条
  • 公司注册地址挂靠费用seo搜索引擎优化包邮
  • 怎么申请 免费网站空间爱站网排行榜
  • 智慧团建系统官方网站登录品牌推广方案
  • 鹤山网站建设易搜互联欧洲网站服务器
  • 做家乡网站源代码网站案例
  • 地区网站建设如何让自己网站排名提高