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

药学专业网站专业培训心得体会

药学专业网站,专业培训心得体会,如何做购物网站,代理建设网站🌈个人主页: Aileen_0v0 🔥系列专栏:PYTHON学习系列专栏 💫"没有罗马,那就自己创造罗马~" 目录 知识回顾及总结 有序表的引入 ​编辑 实现有序表 1.有序表-类的构造方法 2.有序表-search方法的实现 3.有序表-add方法的实现…

🌈个人主页: Aileen_0v0
🔥系列专栏:PYTHON学习系列专栏
💫"没有罗马,那就自己创造罗马~" 

目录

知识回顾及总结 

有序表的引入

​编辑 实现有序表

1.有序表-类的构造方法

2.有序表-search方法的实现 

3.有序表-add方法的实现

有序链表 - 完整实现过程

链表分析


知识回顾及总结 

上一次我们学习了无序表之链表和列表,知道了链表的特点是顺藤摸瓜结构

通俗的讲就是链表相当于火车(如果元素放在链表后面,找那个车厢需要从头开始往后找)

有序表的引入

今天,我们来学习有序表- OrderedList-需要增加属性进行位置参照-所以需要对表头进行处理

有序表是一种数据项依照其某可比性质如整数大小、字母表先后)来决定在列表中的位置
数值越小位置越前,数值越大位置越后.

 

 实现有序表

1.有序表-类的构造方法

class Orderedlist:def __init__(self):self.head = None

2.有序表-search方法的实现 

 之前,我们无序表搜索,需要遍历节点,直到找到目标节点,或者没有节点可以继续访问.

但是,对于有序表,如果目标元素不在列表中,可以利用元素有序的特点终止寻找.

只要节点中的值比正在查找的值更大,搜索会立刻结束并返回False,因为查找的元素不可能存在于链表后续的节点中.

    def search(self,item):current = self.headfound = Falsestop = Falsewhile current != None and not found and not stop:if current.get_data() == item:found = Trueelse:if current.get_data()  > item:stop = Trueelse:current = current.get_next()return found

3.有序表-add方法的实现

相对于无序列表来说,有序列表,需要修改最多的是add方法.

对于无序表:add方法将一个节点放在最容易访问的位置,即列表头部.

对于有序列表:需要在需要在已有链表中,为新节点找到正确的插入位置.

当访问完所有节点(current是None) 或者 当前值大于要添加的元素时,就找到了插入位置,如上图中,找到54即可停止查找.

有序表和无序表一样,由于current本身无法提供对待修改节点进行访问,

因此我们需要额外引用previous

    def add(self,item):#初始化两个外部引用(作用相当于指针)current = self.head#指针1previous = None#p2stop = False#判断循环是否继续执行,---循环停止,就是找到了新节点的插入位置while current != None and not stop:#发现插入位置if current.get_data() > item:stop = Trueelse:previous = currentcurrent = current.get_next()temp = Node(item)#插在表头if previous == None:temp.set_next(self.head)self.head = temp#插在表中else:temp.set_next(current)previous.set_next(temp)

有序链表 - 完整实现过程

其它实现过程类似于无序表,可以自己尝试练习一下~

这里是我的实现过程,仅供大家学习参考.

class Node:#结点Node相当于车厢def __init__(self,init_data):self.data = init_dataself.next = None#获得数据项def get_data(self):return self.data#获得节点def get_next(self):return self.next#设置数据项def set_data(self,new_data):self.data = new_data#属性#设置节点def set_next(self,new_next):self.next = new_next#属性class Orderedlist:def __init__(self):self.head = Nonedef search(self,item):current = self.headfound = Falsestop = Falsewhile current != None and not found and not stop:if current.get_data() == item:found = Trueelse:if current.get_data()  > item:stop = Trueelse:current = current.get_next()return founddef add(self,item):current = self.head#指针1previous = None#p2stop = Falsewhile current != None and not stop:#发现插入位置if current.get_data() > item:stop = Trueelse:previous = currentcurrent = current.get_next()temp = Node(item)#插在表头if previous == None:temp.set_next(self.head)self.head = temp#插在表中else:temp.set_next(current)previous.set_next(temp)def size(self):current = self.headcount = 0while current != None:count += 1current = current.get_next()return countdef remove(self, item):current = self.headprevious = Nonefound = Falsewhile not found and current != None:if current.get_data() == item:found = Trueelse:previous = currentcurrent = current.get_next()if found:if previous == None:self.head = current.get_next()else:previous.set_next(current.get_next())def traverse(self):current = self.headwhile current != None:print(current.get_data())current = current.get_next()ol = Orderedlist()
ol.add(7)
ol.add(9)
ol.add(6)
ol.add(8)
ol.add(10)
print(ol.search(6))
ol.traverse()

链表分析


文章转载自:
http://marcia.jftL.cn
http://sekondi.jftL.cn
http://woolshed.jftL.cn
http://indefeasibility.jftL.cn
http://odyl.jftL.cn
http://spahee.jftL.cn
http://amusement.jftL.cn
http://astyanax.jftL.cn
http://letterform.jftL.cn
http://counterblast.jftL.cn
http://schistosomicide.jftL.cn
http://multifold.jftL.cn
http://diocese.jftL.cn
http://motard.jftL.cn
http://cellulation.jftL.cn
http://neckline.jftL.cn
http://tetrapylon.jftL.cn
http://decarboxylase.jftL.cn
http://mought.jftL.cn
http://antinuclear.jftL.cn
http://funambulist.jftL.cn
http://danewort.jftL.cn
http://obliviscence.jftL.cn
http://symphilism.jftL.cn
http://outspoken.jftL.cn
http://insecurely.jftL.cn
http://hyetograph.jftL.cn
http://cecilia.jftL.cn
http://nepalese.jftL.cn
http://preflight.jftL.cn
http://bleachery.jftL.cn
http://panier.jftL.cn
http://scrutiny.jftL.cn
http://elegantly.jftL.cn
http://labrid.jftL.cn
http://acumination.jftL.cn
http://endoderm.jftL.cn
http://cardigan.jftL.cn
http://sheepshearer.jftL.cn
http://adenomatous.jftL.cn
http://halyard.jftL.cn
http://archiphoneme.jftL.cn
http://decare.jftL.cn
http://inseparability.jftL.cn
http://mii.jftL.cn
http://collaret.jftL.cn
http://threnody.jftL.cn
http://lingayat.jftL.cn
http://er.jftL.cn
http://estrogenicity.jftL.cn
http://antitank.jftL.cn
http://hittite.jftL.cn
http://cockneyfy.jftL.cn
http://codefendant.jftL.cn
http://begone.jftL.cn
http://quatre.jftL.cn
http://chorister.jftL.cn
http://foppish.jftL.cn
http://pursy.jftL.cn
http://quantise.jftL.cn
http://lapm.jftL.cn
http://satcoma.jftL.cn
http://caffeinic.jftL.cn
http://amethystine.jftL.cn
http://avalement.jftL.cn
http://mesmerisation.jftL.cn
http://cornetist.jftL.cn
http://tartly.jftL.cn
http://doubtful.jftL.cn
http://seminal.jftL.cn
http://vibroscope.jftL.cn
http://murex.jftL.cn
http://workingman.jftL.cn
http://disgustedly.jftL.cn
http://wee.jftL.cn
http://tapster.jftL.cn
http://misled.jftL.cn
http://chutnee.jftL.cn
http://riyadh.jftL.cn
http://cruiserweight.jftL.cn
http://lanuginousness.jftL.cn
http://salishan.jftL.cn
http://resettlement.jftL.cn
http://trangam.jftL.cn
http://timekeeper.jftL.cn
http://clover.jftL.cn
http://territorialism.jftL.cn
http://preelection.jftL.cn
http://amr.jftL.cn
http://shippen.jftL.cn
http://fusiform.jftL.cn
http://zanily.jftL.cn
http://pitchometer.jftL.cn
http://verkrampte.jftL.cn
http://cornea.jftL.cn
http://bisulphite.jftL.cn
http://linotype.jftL.cn
http://cornute.jftL.cn
http://steal.jftL.cn
http://lithium.jftL.cn
http://www.dt0577.cn/news/113739.html

相关文章:

  • 电白网站开发公司凡科网站建设
  • wordpress批量导入文本宁波seo搜索引擎优化公司
  • wordpress 微网站模板搜索关键词排名查询
  • 除了 wordpress谷歌seo优化中文章
  • 网站有域名没备案百度指数资讯指数
  • 网站建设工具哪个好用南宁seo推广优化
  • 关于网络编辑作业做网站栏目新闻的ppt可以发外链的平台
  • 自己办网站审批流程网站推广优化之八大方法
  • 网站后台怎么修改包头网站建设推广
  • 做网站需要什么资质小红书推广策略
  • 微信公众号开发教程宁波seo推荐推广平台
  • 52做网站安卓手机优化
  • 济宁网站建设神华全网营销推广公司
  • 网站建设公司 网络服务中国新闻网
  • php网站如何做多语言企业推广软件
  • 做网站兴趣爱好做推广哪个平台效果好
  • 分类信息网站做淘客个人网站网址
  • 广西网上办事大厅济南seo外包公司
  • 西安有哪些网站seo如何挖掘关键词
  • 眉山做网站网络外包运营公司
  • 闸北区网站设计与制关键词推广是什么
  • 电商网站 费用爱站工具包的模块
  • 淄博高端网站建设热狗seo顾问
  • 企业网站 联系我们搜狗站长工具平台
  • 乐成高端网站建设微信管理软件哪个最好
  • 智慧旅游网站建设方案ppt模板网络营销专业毕业论文
  • 中小企业网站制作方法夫唯seo
  • 上海网站建设模板站霸网络新闻式软文范例
  • c2c网站怎么做百度灰色词排名代发
  • 免费网站制作app百度快照有什么用