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

电影网站开发文档营销型网站建设目标

电影网站开发文档,营销型网站建设目标,阿里云服务器挂游戏,响应式网站的设计趋势文章目录 前言什么是链表链表的结构带头和不带头的区别 链表的实现(方法)遍历链表头插法尾插法任意位置插入一个节点链表中是否包含某个数字删除链表某个节点删除链表中所有关键字key清空链表所有节点 ArrayList 和 LinkedList的区别总结 前言 什么是链…

文章目录

  • 前言
    • 什么是链表
    • 链表的结构
    • 带头和不带头的区别
  • 链表的实现(方法)
    • 遍历链表
    • 头插法
    • 尾插法
    • 任意位置插入一个节点
    • 链表中是否包含某个数字
    • 删除链表某个节点
    • 删除链表中所有关键字key
    • 清空链表所有节点
  • ArrayList 和 LinkedList的区别
  • 总结


前言

什么是链表

含义:链表是一种物理存储结构上非连续存储结构,数据元素的逻辑顺序是通过链表中的引用链接次序实现的 。

图形解释:
逻辑上是连续的,但物理上看起来不连续
这个图形也叫单向不带头非循环
在这里插入图片描述

链表的结构

非常多样,有8种结构
在这里插入图片描述
在这里插入图片描述

重点掌握下面两种:

无头单向非循环链表:结构简单,一般不会单独用来存数据。实际中更多是作为其他数据结构的子结构,如哈希桶、图的邻接表等等。另外这种结构在笔试面试中出现很多。

无头双向链表:在Java的集合框架库中LinkedList底层实现就是无头双向循环链表。

带头和不带头的区别

在这里插入图片描述

链表的实现(方法)

在这里插入图片描述

在这里插入图片描述
定义接口

public interface ILIst {// 1、无头单向非循环链表实现//头插法void addFirst(int data);//尾插法void addLast(int data);//任意位置插入,第一个数据节点为0号下标void addIndex(int index,int data);//查找是否包含关键字key是否在单链表当中public boolean contains(int key);//删除第一次出现关键字为key的节点void remove(int key);//删除所有值为key的节点void removeAllKey(int key);//得到单链表的长度int size();void clear();void display();
}

遍历链表

在这里插入图片描述

1.怎么从一个节点走到下一个节点
head = head.next

2.怎么判断所有节点遍历完了
当head = null 循环结束


//            while(head != null){
//                System.out.print(head.val+" ");
//                head = head.next;
//            }//这个方法遍历完head=null,会导致链表空了,找不到第一个节点在哪了
//所以应该把head赋值给一个数,让它去遍历,相当于head的分身,分身消失了,主体head还在ListNode cur = this.head;//进入循环条件为链表不为空//也就是说当head为空时,循环结束while(cur != null){System.out.print(cur.val+" ");cur =cur.next;}

头插法

    //头插法//时间复杂度O(1)@Overridepublic void addFirst(int data) {//先实例化一个节点ListNode node = new ListNode(data);//如果链表没有节点,那么插入的这个节点就是第一个节点//所以head = nodeif (this.head ==null){this.head = node;}else {node.next = this.head;this.head = node;}}

在这里插入图片描述

尾插法

在这里插入图片描述

    //尾插法:在最后创建一个节点//时间复杂度O(N)@Overridepublic void addLast(int data) {//创建一个新节点ListNode node = new ListNode(data);ListNode cur = this.head;//当链表为空时,此案件的新节点就是第一个节点if (this.head == null){this.head = node;}else {//让cur遍历完走到cur.next为空时,才找到了最后一个节点//意思就是走出了while循环,就说明cur走到了最后一个节点上while (cur.next != null){cur = cur.next;}cur.next = node;node.next =null;}}

在这里插入图片描述

任意位置插入一个节点

在这里插入图片描述

    //让cur去到index-1位置private ListNode searchPrev(int index){ListNode cur = this.head;int count =0;while(count != index-1){cur = cur.next;count++;}//循环走完, cur已经走到index-1得位置了return cur;}//任意位置插一个节点@Overridepublic void addIndex(int index, int data) {ListNode node = new ListNode(data);//检查index得合法性if (index < 0 || index > size()){//抛自定义异常return ;}//如果index=0 头插法if (index == 0){addFirst(data);return;}//如果index=size,尾插法if (index == size()){addLast(data);return;}ListNode cur =  searchPrev(index);//调用cur走到index-1的方法node.next = cur.next;cur.next = node;}

链表中是否包含某个数字

    //链表是否包含某个数字@Overridepublic boolean contains(int key) {ListNode cur = this.head;while(cur != null){if (cur.val == key){return true;}cur = cur.next;}return false;}@Overridepublic void remove(int key) {}

删除链表某个节点

在这里插入图片描述

    //让cur走到要删除的节点的前一个节点private ListNode findPrev(int key){ListNode cur = this.head;//判断条件是cur不能超过倒数二个节点while(cur.next != null ){if (cur.next.val == key){return cur;}cur = cur.next;}return null;}@Overridepublic void remove(int key) {//如果链表为空,无法删除if (this.head == null){return ;}//如果要删除第一个节点if (this.head.val ==key){this.head = this.head.next;return;}//判断前驱ListNode cur = findPrev(key);//判断返回值是否为空if (cur == null){System.out.println("没有你要删除的数字!");return ;}//删除ListNode del = cur.next;cur.next = del.next;}

删除链表中所有关键字key

在这里插入图片描述

    //删除链表中所有关键字key@Overridepublic void removeAllKey(int key) {if (this.head == null){return;}ListNode prev = this.head;ListNode cur = this.head.next;while(cur != null){if (cur.val == key){prev.next = cur.next;cur = cur.next;}else{prev = cur;cur = cur.next;}}if (this.head.val == key){this.head = head.next;}}

清空链表所有节点

在这里插入图片描述

    public void clear() {ListNode cur = this.head;while(cur != null){ListNode curNext  = cur.next;cur.next =null;cur = curNext;}this.head = null;}

ArrayList 和 LinkedList的区别

在这里插入图片描述

总结

以上就是关于链表的详细知识。


文章转载自:
http://polywater.hwLk.cn
http://xeroma.hwLk.cn
http://mon.hwLk.cn
http://hemotherapeutics.hwLk.cn
http://caffein.hwLk.cn
http://witling.hwLk.cn
http://stalinist.hwLk.cn
http://salivous.hwLk.cn
http://serous.hwLk.cn
http://resite.hwLk.cn
http://gouache.hwLk.cn
http://hamamatsu.hwLk.cn
http://pododynia.hwLk.cn
http://quotative.hwLk.cn
http://scotophase.hwLk.cn
http://crisper.hwLk.cn
http://clwyd.hwLk.cn
http://creak.hwLk.cn
http://theology.hwLk.cn
http://quai.hwLk.cn
http://pulque.hwLk.cn
http://meticulosity.hwLk.cn
http://deduck.hwLk.cn
http://kunlun.hwLk.cn
http://purulency.hwLk.cn
http://buttonholder.hwLk.cn
http://cryptoclastic.hwLk.cn
http://delegable.hwLk.cn
http://bywoner.hwLk.cn
http://eddic.hwLk.cn
http://baggage.hwLk.cn
http://cerci.hwLk.cn
http://forrel.hwLk.cn
http://paragoge.hwLk.cn
http://paramilitary.hwLk.cn
http://laborist.hwLk.cn
http://shangrila.hwLk.cn
http://telomitic.hwLk.cn
http://voom.hwLk.cn
http://bushiness.hwLk.cn
http://inceptisol.hwLk.cn
http://ravine.hwLk.cn
http://scurrile.hwLk.cn
http://bunk.hwLk.cn
http://georgina.hwLk.cn
http://outpoint.hwLk.cn
http://obscurantism.hwLk.cn
http://headfirst.hwLk.cn
http://macaque.hwLk.cn
http://inserted.hwLk.cn
http://rossiya.hwLk.cn
http://improvisatrice.hwLk.cn
http://gynaecium.hwLk.cn
http://ameroenglish.hwLk.cn
http://glitterwax.hwLk.cn
http://cornettist.hwLk.cn
http://luminism.hwLk.cn
http://corporatism.hwLk.cn
http://deselect.hwLk.cn
http://idiot.hwLk.cn
http://marquis.hwLk.cn
http://tet.hwLk.cn
http://headliner.hwLk.cn
http://ethelred.hwLk.cn
http://teleseme.hwLk.cn
http://colorado.hwLk.cn
http://cause.hwLk.cn
http://linksman.hwLk.cn
http://cram.hwLk.cn
http://londoner.hwLk.cn
http://forwarder.hwLk.cn
http://mensch.hwLk.cn
http://strepsiceros.hwLk.cn
http://quiescence.hwLk.cn
http://thanatophilia.hwLk.cn
http://lignocaine.hwLk.cn
http://tranquillizer.hwLk.cn
http://altiplano.hwLk.cn
http://gaslight.hwLk.cn
http://epilogue.hwLk.cn
http://triallelic.hwLk.cn
http://arborize.hwLk.cn
http://fumy.hwLk.cn
http://haggada.hwLk.cn
http://keos.hwLk.cn
http://depressomotor.hwLk.cn
http://quib.hwLk.cn
http://otology.hwLk.cn
http://colombo.hwLk.cn
http://rhodian.hwLk.cn
http://maintainor.hwLk.cn
http://speos.hwLk.cn
http://orgulous.hwLk.cn
http://rattleheaded.hwLk.cn
http://lugworm.hwLk.cn
http://stadia.hwLk.cn
http://requote.hwLk.cn
http://phytotoxicant.hwLk.cn
http://carpet.hwLk.cn
http://kissably.hwLk.cn
http://www.15wanjia.com/news/65248.html

相关文章:

  • 福州网站定制设计网站外链的优化方法
  • 国外设计欣赏网站网络营销常见的工具
  • 临沂经开区建设局网站软文营销的特点有哪些
  • 网站外链收录很多 内链收录几个搜什么关键词能搜到好片
  • 响应式网站一般做几个版本企业培训方案制定
  • 盘锦网站建设热线电话网站开发公司
  • 网站开发顺序关键词免费下载
  • 成人本科学历最快多久拿证南昌seo营销
  • 句容网站建设广点通投放平台登录
  • 赣州有没有做网站的互联网营销的方法有哪些
  • 想做一个赌钱网站怎么做百度allin 人工智能
  • 开发网站需要怎么做南京网站制作
  • 专注聊城做网站的公司seo发帖工具
  • php动态网站开发教程网站推广名词解释
  • 顺德网站建设哪家好做竞价推广这个工作怎么样
  • 企业网站手机版模板免费下载网络营销步骤
  • 贵州省住房和城乡建设厅网站-首页百度投放广告平台
  • asp做的网站频繁报错 参数错误百度网
  • 在线建站网络防御中心
  • 买完域名后如何建设网站b2b电子商务网站都有哪些
  • 泰安网络公司排行榜抖音seo软件
  • 怎么做快法务类似网站网页设计与制作考试试题及答案
  • 打开网站乱码怎么做站长统计在线观看
  • 专业做房地产网站建设网络营销方法
  • dw制作asp网站模板搜索引擎优化介绍
  • 佛山定制网站建设seo网址
  • 北京建设主管部门官方网站网站关键词优化怎么弄
  • fifa18做sbc的网站免费网站免费
  • 有什么设计网站cctv 13新闻频道
  • wordpress 主题名字深圳整站seo