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

贵州做网站怎么推广seo白帽优化

贵州做网站怎么推广,seo白帽优化,学生做网站作品图片,学院网站建设作用文章目录 数据结构和算法,单链表的实现(kotlin版)b站视频链接1.定义接口,我们需要实现的方法2.定义节点,表示每个链表节点。3.push(e: E),链表尾部新增一个节点4.size(): Int,返回链表的长度5.getValue(index: Int): E…

文章目录

  • 数据结构和算法,单链表的实现(kotlin版)
    • b站视频链接
    • 1.定义接口,我们需要实现的方法
    • 2.定义节点,表示每个链表节点。
    • 3.push(e: E),链表尾部新增一个节点
    • 4.size(): Int,返回链表的长度
    • 5.getValue(index: Int): E?,获取列表的value值
    • 6.insert(index: Int,e: E),从任意位置插入一个节点
    • 7.remove(index: Int),任意位置删除一个节点
    • 8.完整Demo

数据结构和算法,单链表的实现(kotlin版)

b站视频链接

单链表的实现–koltin版本

1.定义接口,我们需要实现的方法

interface LinkedListAction<E> {fun push(e: E)fun size(): Intfun getValue(index: Int): E?fun insert(index: Int,e: E)fun remove(index: Int)
}

2.定义节点,表示每个链表节点。

data class Node<E>(var next: Node<E>? = null, var value: E)

3.push(e: E),链表尾部新增一个节点

override fun push(e: E) {val newNode = Node(null, e)if (head != null) {
//            val lastNode = node(len - 1)//O(1)时间复杂度last?.next = newNode} else {head = newNode}last = newNodelen++}

4.size(): Int,返回链表的长度

override fun size(): Int {return len}

5.getValue(index: Int): E?,获取列表的value值

    override fun getValue(index: Int): E? {if (index < 0 || index >= len) {throw ArrayIndexOutOfBoundsException("数组越界.....")}return node(index)?.value}//找到对应index下标的节点。private fun node(index: Int): Node<E>? {var h = head//O(n)时间复杂度for (i in 0 until index) {h = h?.next}return h}

6.insert(index: Int,e: E),从任意位置插入一个节点

override fun insert(index: Int, e: E) {val newNode = Node(null, e)//考虑边界if (index == 0) {val h = headhead = newNodenewNode.next = h} else {//考虑最后一个位置val prev = node(index - 1)val next = prev?.nextprev?.next = newNodenewNode.next = next}len++}//找到对应index下标的节点。private fun node(index: Int): Node<E>? {var h = head//O(n)时间复杂度for (i in 0 until index) {h = h?.next}return h}

7.remove(index: Int),任意位置删除一个节点

override fun remove(index: Int) {if (index < 0 || index >= len) {throw ArrayIndexOutOfBoundsException("数组越界.....")}if (index == 0) {val h = headhead = h?.nexth?.next = null} else {val prev = node(index - 1)val current = prev?.nextprev?.next = current?.nextcurrent?.next = null}len--}//找到对应index下标的节点。private fun node(index: Int): Node<E>? {var h = head//O(n)时间复杂度for (i in 0 until index) {h = h?.next}return h}

8.完整Demo

package day1class LinkedList<E> : LinkedListAction<E> {//头指针private var head: Node<E>? = null//优化时间复杂度private var last: Node<E>? = null//集合的长度private var len = 0override fun push(e: E) {val newNode = Node(null, e)if (head != null) {
//            val lastNode = node(len - 1)//O(1)时间复杂度last?.next = newNode} else {head = newNode}last = newNodelen++}//找到对应index下标的节点。private fun node(index: Int): Node<E>? {var h = head//O(n)时间复杂度for (i in 0 until index) {h = h?.next}return h}override fun size(): Int {return len}override fun getValue(index: Int): E? {if (index < 0 || index >= len) {throw ArrayIndexOutOfBoundsException("数组越界.....")}return node(index)?.value}override fun insert(index: Int, e: E) {val newNode = Node(null, e)//考虑边界if (index == 0) {val h = headhead = newNodenewNode.next = h} else {//考虑最后一个位置val prev = node(index - 1)val next = prev?.nextprev?.next = newNodenewNode.next = next}len++}override fun remove(index: Int) {if (index < 0 || index >= len) {throw ArrayIndexOutOfBoundsException("数组越界.....")}if (index == 0) {val h = headhead = h?.nexth?.next = null} else {val prev = node(index - 1)val current = prev?.nextprev?.next = current?.nextcurrent?.next = null}len--}}
http://www.khdw.cn/news/44213.html

相关文章:

  • 用react做的网站上传百度百度一下一下
  • 男和男人怎么做那个视频网站重庆seo主管
  • 怎么形容网站做的很好网络服务提供者收集和使用个人信息应当符合的条件有
  • 嘉定网站设计童程童美少儿编程怎样收费
  • wordpress 标题天津做优化好的公司
  • 建设电商网站所需硬件seo网站编辑是做什么的
  • dw创建网站导航栏菜单怎么做百度模拟点击软件判刑了
  • 做的好的农产品网站近期国际热点大事件
  • 济南网站建设 伍际网络关键词列表
  • 免费的网站怎么做谷歌广告上海有限公司
  • 网站建设 作用营销策划有限公司经营范围
  • 网站怎么做网页百度收录查询
  • 大恒建设集团有限公司网站深圳抖音推广公司
  • web浏览器手机版下载网络排名优化软件
  • wordpress 模板丢失武汉seo网站优化运营
  • 电商网站代码百度seo推广方案
  • 公司为什么做网站长沙谷歌seo
  • 无锡网站seo报价海口百度seo公司
  • 同德县网站建设公司百度搜索广告推广
  • 杭州网站建设公司联系方式站长工具四叶草
  • wordpress企业站手机客户端爱上链外链购买平台
  • 中文的网站做不成二维码优化seo方法
  • 商城管理系统seo流量优化
  • 建一个购物网站多少钱百度竞价代理公司
  • 网站制作技术有哪些seo百度网站排名研究中心关键词首页优化
  • 网站推广的案例seo优化教程自学
  • 长沙网站制作多少钱保定网站推广公司
  • 安徽政府网站建设2022年每日新闻摘抄10一30字
  • 成免费crm特色学生版的特点app优化建议
  • 最好的微网站建设价格百度收藏夹使用方法