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

淄博网站制作首选专家河源网站推广

淄博网站制作首选专家,河源网站推广,it培训机构哪个好一点,mysql网站后台管理系统下载单链表删除整表Deletion can be at various positions like: 删除可以在各个位置进行#xff0c;例如#xff1a; Deleting the first node 删除第一个节点 Deleting the last node 删除最后一个节点 Deleting the intermediate node 删除中间节点 删除单个链表中的第一个节…单链表删除整表Deletion can be at various positions like: 删除可以在各个位置进行例如 Deleting the first node 删除第一个节点 Deleting the last node 删除最后一个节点 Deleting the intermediate node 删除中间节点 删除单个链表中的第一个节点 (Deleting the first node in single linked list) In such case, the head node is to be removed and the next node needs to be assigned as updated head node. 在这种情况下将删除头节点并且需要将下一个节点分配为更新的头节点。 Create a temporary node, say temp which points to the head node (first node) of the list. 创建一个临时节点例如temp 它指向列表的头节点(第一个节点)。 Move head node pointer to the immediate next node and delete (dispose) the temp node. 将头节点指针移动到紧邻的下一个节点然后删除(布置)临时节点。 删除单个链接列表中的最后一个节点 (Deleting the last node in the single linked list) In such case the last node is to be removed from list. The steps are following: 在这种情况下最后一个节点将从列表中删除。 步骤如下 We need to keep track of the previous node of last node. Thats why while traversing to the last node we need to set a prev node also which will point to the previous node of the tail node( last node) after traversal. 我们需要跟踪最后一个节点的前一个节点。 这就是为什么在遍历到最后一个节点时我们还需要设置一个prev节点该节点将在遍历后指向尾节点(最后一个节点)的前一个节点。 So, we have two pointer, one tail node pointing to the last node and another is prev node pointing to the previous node of the last node. 因此我们有两个指针一个尾节点指向最后一个节点另一个是上一个节点指向最后一个节点的前一个节点。 Set the next pointer of the prev node to NULL and delete the tail node. (last node) 将上一个节点为NULL的下一个指针并删除尾节点。 (最后一个节点) 删除单个链接列表中的中间节点 (Deleting an intermediate node in the single linked list) In such case an intermediate node is to be deleted. The approach is quite similar to the previous. 在这种情况下中间节点将被删除。 该方法与以前的方法非常相似。 Similar to the previous case, a curr node and a prev node is to be maintained. Curr node will point to the node to be deleted and prev node will point to the previous node. 与前一种情况类似将保留curr节点和prev节点。 Curr节点将指向要删除的节点而prev节点将指向上一个节点。 Set the next pointer of the prev node to the next pointer of curr node. 在上一个节点的next指针设置为CURR节点的下一个指针。 Delete the curr node. 删除curr节点。 .minHeight{ min-height: 250px; } @media (min-width: 1025px){ .minHeight{ min-height: 90px; } } .minHeight{ min-height: 250px; } @media (min-width: 1025px){ .minHeight{ min-height: 90px; } } 链表中删除的C实现 (C implementation of deletion in a linked list) #include stdio.h #include stdlib.h struct node{ int data; // data field struct node *next; }; void traverse(struct node* head){ struct node* currenthead; // current node set to head int count0; // to count total no of nodes printf(\n traversing the list\n); while(current!NULL){ //traverse until current node isnt NULL count; //increase node count printf(%d ,current-data); currentcurrent-next; // go to next node } printf(\ntotal no of nodes : %d\n,count); } struct node* creatnode(int d){ struct node* tempmalloc(sizeof(struct node)); temp-datad; temp-nextNULL; return temp; } int main(){ printf(creating the linked list by inserting new nodes at the begining\n); printf(enter 0 to stop building the list, else enter any integer\n); int k,count1,x; struct node* curr,*temp,*prev; scanf(%d,k); struct node* headcreatnode(k); //buliding list, first node scanf(%d,k); ///inserting at begining// while(k){ currcreatnode(k); curr-nexthead; //inserting each new node at the begining headcurr; scanf(%d,k); } traverse(head); // displaying the list deleting the first node printf(\ndeleting the first node.............\n); temphead; // first node assigned to temp headhead-next; // head node is updated free(temp); // deleting the first node traverse(head); // displaying the list printf(\nfirst node deleted...............\n); /deleting the last node printf(\ndeleting the last node.............\n); temphead-next; prevhead; while(temp-next!NULL){ temptemp-next; prevprev-next; } // after traversal temp points to the last //node and prev to the previous node of the last node prev-nextNULL; free(temp); traverse(head); printf(\last node deleted................\n); ///deleting any intermediate node in the list printf(\n enter the position of the node you want to delete\n); scanf(%d,x); temphead-next; prevhead; while(count!x-1){ temptemp-next; prevprev-next; count; } // temp pointing to the node to be deleted and prev to the previous node prev-nexttemp-next; free(temp); traverse(head); return 0; } Output 输出量 creating the linked list by inserting new nodes at the begining enter 0 to stop building the list, else enter any integer 1 2 3 4 5 6 7 8 9 0 traversing the list 9 8 7 6 5 4 3 2 1 total no of nodes : 9 deleting the first node............. traversing the list 8 7 6 5 4 3 2 1 total no of nodes : 8 first node deleted............... deleting the last node............. traversing the list 8 7 6 5 4 3 2 total no of nodes : 7 last node deleted................ enter the position of the node you want to delete 5 traversing the list 8 7 6 5 3 2 total no of nodes : 6 翻译自: https://www.includehelp.com/data-structure-tutorial/single-linked-list-deletion.aspx单链表删除整表
http://www.pierceye.com/news/597328/

相关文章:

  • 考幼师证去哪个网站做试题如何分析网站建设
  • 济南智能网站建设哪家好化工网站建设推广
  • 福州 网站定制设计稿定设计官方免费下载
  • 统计局网站建设情况南宁做网站优化的公司
  • 免费的软件网站建设北京建设厅网站查询
  • 没有公司做网站短网址短链接生成器
  • 利于seo优化的网站网站怎么上传到空间
  • 寿阳网站建设开发网站的硬件成本
  • 做网站的叫什么软件众筹网站开发
  • 鲜花网网站开发的目标河南郑州建设网站
  • 做网站上哪买空间帝国网站管理系统安装连接不上数据库
  • 做前端网站用什么工具网站备案后怎么做实名认证
  • 做兼职那个网站比较好重庆的seo服务公司
  • 网站建设流费用南通seo排名公司
  • 河北邢台移动网站建设单片机做网站
  • 佛山网站制作的公司做文库网站怎么赚钱吗
  • 博客网站 做淘宝客咸阳网站建设推广
  • 佛山手机网站建设优化做网站要多大的画布
  • 网站结构优化包括什么网站建设定制开发
  • 做装修的有那些网站wordpress获取用户位置
  • 找事做网站公司网站网页设计
  • 网站数据哪个网站可以做图片
  • 网站添加google地图阿里云服务器可以访问国外网站吗
  • 大连免费网站制作重庆哪些网站推广公司
  • 查建设工程规划许可证网站广州模板建站公司
  • 怎么做网站的超级链接有哪些做的很漂亮的网站
  • 做旅游网站挣钱吗wordpress 虎嗅网
  • 乐清网站制作的公司php 网站源代码
  • 外国知名个人网站衡阳做网站公司
  • 女人网站源码沈阳大型网站制作公司