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

备案ip 查询网站查询网站查询深圳鲜花团购网站建设

备案ip 查询网站查询网站查询,深圳鲜花团购网站建设,如何对seo进行优化,网站预订功能怎么做有这么一句话说“程序数据结构算法”#xff0c;也有人说“如果把编程比作做菜#xff0c;那么数据结构就好比食材#xff08;菜#xff09;#xff0c;算法就好比厨艺#xff08;做菜的技巧#xff09;”。 当然这是笼统的说法#xff0c;不过也稍微懂得了数据结构和…有这么一句话说“程序数据结构算法”也有人说“如果把编程比作做菜那么数据结构就好比食材菜算法就好比厨艺做菜的技巧”。 当然这是笼统的说法不过也稍微懂得了数据结构和算法的重要性了。 其实数据结构是数据间的有机关系而算法是对数据的操作步骤两者不可分开来谈不能脱离算法来讨论数据结构也不能脱离数据结构研究算法。 在网上看到这样一段话 数据结构并不是来教你怎样编程的同样编程语言的精练也不在数据结构的管辖范围之内那是教你学习一门语言的老师的事情他肯定不想因为数据结构而失业。数据结构是教你如何在现有程序的基础上把它变得更优运算更快占用资源更少它改变的是程序的存储运算结构而不是程序语言本身。 如果把程序看成一辆汽车那么程序语言就构成了这辆车的车身和轮胎。而算法则是这辆车的核心——发动机。这辆车跑得是快是慢关键就在于发动机的好坏当然轮胎太烂了也不行而数据结构就是用来改造发动机的。 可以这么说数据结构并不是一门语言它是一种思想一种方法一种思维方式。它并不受语言的限制你完全可以在gave 中轻而易举地实现一个用C语言给出的算法。 或许你在初入职场的时候并不会涉及到需要使用到数据结构的地方也因而觉得数据结构貌似没用但这和“农民工也能盖大楼干嘛还学建筑呢” 是一个道理应该都懂。 前面说了超长的废话其实我是想介绍一些数据结构的学习资源主要针对编程新手希望可以解决新手们“如何学习数据结构”的困惑若对你有所帮助那真是极好的。 浅谈单链表与双链表的区别 用代码解释两种结构--- 单链表 class Node:def __init__(self, data):self.data dataself.next Nonedef __str__(self):return str(self.data)# 通过单链表构建一个list的结构 添加 删除 插入 查找 获取长度 判断是否为空... # list1 [] list1.append(5) [5,] slist SingleList() slist.append(5) class SingleList:def __init__(self, nodeNone):self._head nodedef isEmpty(self):return self._head Nonedef append(self, item):# 尾部添加node Node(item)if self.isEmpty():self._head nodeelse:cur self._headwhile cur.next ! None:cur cur.nextcur.next node# 求长度def len(self):cur self._headcount 0while cur ! None:count 1cur cur.nextreturn count# 遍历def print_all(self):cur self._headwhile cur ! None:print(cur)cur cur.nextdef pop(self, index):if index 0 or index self.len():raise IndexError(index Error)if index 0:self._head self._head.nextelse:cur self._head# 找到当前下标的前一个元素while index - 1:cur cur.nextindex - 1# 修改的next的指向位置cur.next cur.next.nextdef insert(self, index, item):if index 0 or index self.len():raise IndexError(index Error)if isinstance(item, Node):raise TypeError(不能是Node类型)else:node Node(item)if index 0:node.next self._headself._head nodeelse:cur self._headwhile index - 1:cur cur.nextindex - 1node.next cur.nextcur.next nodedef update(self, index, new_item):if index 0 or index self.len():raise IndexError(index Error)if isinstance(new_item, Node):raise TypeError(不能是Node类型)else:node Node(new_item)if index 0:node.next self._head.nextself._head nodeelse:cur self._headnode.next cur.next.nextcur.next nodedef remove(self, item):if isinstance(item, Node):raise TypeError(不能是Node类型)else:node Node(item)cur self._headwhile cur node:cur cur.nextcur.next cur.next.nextif __name__ __main__:slist SingleList()print(slist.isEmpty()) # Trueprint(slist.len())slist.append(5)print(slist.isEmpty()) # Falseprint(slist.len()) # 1slist.append(8)slist.append(6)slist.append(3)slist.append(1)print(slist.isEmpty()) # Trueprint(slist.len())print(---------------------)slist.print_all()print(----------pop-------------)slist.pop(2)slist.print_all()print(--------insert-------)slist.insert(1, 19)slist.print_all()print(--------update-------)slist.update(1, 18)slist.print_all()print(--------remove-------)slist.remove(18)slist.print_all()双链表 双向链表 class Node:def __init__(self, data):self.data dataself.next Noneself.prev Nonedef __str__(self):return str(self.data)class DoubleList:def __init__(self):self._head Nonedef isEmpty(self):return self._head Nonedef append(self, item):# 尾部添加node Node(item)if self.isEmpty():self._head nodeelse:cur self._headwhile cur.next ! None:cur cur.nextcur.next node# 求长度def add(self, item):node Node(item)if self.isEmpty():self._head nodeelse:node.next self._headself._head.prev nodeself._head nodedef len(self):cur self._headcount 0while cur ! None:count 1cur cur.nextreturn countdef print_all(self):cur self._headwhile cur ! None:print(cur)cur cur.nextdef insert(self, index, item):if index 0 or index self.len():raise IndexError(index Error)if isinstance(item, Node):raise TypeError(不能是Node类型)else:node Node(item)if index 0:node.next self._headnode.prev self._head.prevself._head nodeelse:cur self._headwhile index - 1:cur cur.nextindex - 1node.next cur.nextnode.prev cur.prevcur.next nodecur.prev node.prevdef remove(self, item):if isinstance(item, Node):raise TypeError(不能是Node类型)else:node Node(item)cur self._headwhile cur node:cur cur.nextcur.next cur.next.nextcur.prev cur.prevdef update(self, index, new_item):if index 0 or index self.len():raise IndexError(index Error)if isinstance(new_item, Node):raise TypeError(不能是Node类型)else:node Node(new_item)if index 0:node.next self._head.nextnode.prev self._head.prevself._head nodeelse:cur self._headnode.next cur.next.nextnode.prev cur.prevcur.next nodecur.prev nodeif __name__ __main__:dlist DoubleList()print(dlist.len())print(dlist.isEmpty())# dlist.append(6)# dlist.append(9)# dlist.append(5)# print(dlist.len())# print(dlist.isEmpty())# dlist.print_all()dlist.add(6)dlist.add(9)dlist.add(5)dlist.print_all()print(--------insert-------)dlist.insert(1, 19)dlist.print_all()print(--------update-------)dlist.update(1, 18)dlist.print_all()print(--------remove-------)dlist.remove(18)dlist.print_all()
http://www.yutouwan.com/news/68437/

相关文章:

  • 网站三要素ui设计师需要考证吗
  • 建设资格注册管理中心网站wordpress加首页
  • 官方网站下载安装云支付深圳市房地产信息网官网
  • 阜宁做网站工作室2022年卡一卡二卡三精品
  • 苏州园区网站设计公司荆门刚刚发布的
  • 网站icp备案代理网站html静态化
  • 公司网站建设方案ppt建立公司网站需要注意什么
  • 站长工具seo优化吉安县规划建设局网站
  • 建站行业前景怎么样微网站怎么做的
  • 自己网站做优化的有权利卖么什么是成交型网站建设
  • 网站后台管理系统很慢亲子乐园网站建设规划
  • 一般公司网站是什么设计师做网站升级中模板
  • 昆明免费网站制作最专业的营销网站建设公司
  • 1m带宽网站支持多少人同时在线淘宝客网站免费模板下载
  • 信誉好的企业网站开发wordpress登录下载文件
  • 企业网站建设可以分为( )交互层次90设计网站最便宜终身
  • 交互动效库 网站南昌做网站哪个好
  • 正确建设企业网站做预定网站的作用
  • 有哪些好的网站建设潍坊建设网站公司电话
  • 九亭做网站公司免费注册qq号网站
  • 唐山医疗网站建设小程序主题wordpress
  • 百度糯米网站怎么做网站页面一般以多大标准做合适
  • 饰品网站建设策划书英文网站建设解决方案
  • 重庆网站搜索推广网站怎么做不违法
  • 金华专业做网站定做app需要多少钱
  • 中交建设集团网站分公司企业公众号运营方案
  • 好的企业官网建设公司外贸网站 seo
  • 网站开发范围说明书最新房地产新闻
  • 开源网站推广昆山网站优化
  • 网站建设需要ui吗全网是哪些平台