博客
关于我
数据结构第三天
阅读量:281 次
发布时间:2019-03-01

本文共 3126 字,大约阅读时间需要 10 分钟。

???????????????

????????????????????????????????????????????????????????????????

1. ???????

??????????????????????????????Python???????????????????????Python???????????????????????????????????????????

?????????????????????????????????????????????????????????????????????????????

2. Python???????

?Python?????????????????????????????????

a = 10b = 20

?????????a?b??????????????????Python?????????????????????????????????????????????????

a, b = b, a

???????????

a, b = 20, 10

????????????????????????????????????????

3. Python?????

??????????????????????????????????????????????

class Node(object):    """???"""    def __init__(self, elem):        self.elem = elem        self.next = None

???????????

  • is_empty()??????????
  • length()????????
  • travel()??????
  • add(item)?????????
  • append(item)?????????
  • insert(pos, item)???????????
  • remove(item)????????
  • search(item)??????????

???????????

class SingleLinkList(object):    """????"""    def __init__(self, node=None):        self.__head = node  # ????    def is_empty(self):        """????????"""        return self.__head is None    def length(self):        """??????"""        count = 0        cur = self.__head        while cur is not None:            count += 1            cur = cur.next        return count    def travel(self):        """???????????"""        cur = self.__head        while cur is not None:            print(cur.elem, end=" ")            cur = cur.next        print()    def add(self, item):        """??????????"""        node = Node(item)        node.next = self.__head        self.__head = node    def append(self, item):        """??????????"""        node = Node(item)        if self.is_empty():            self.__head = node        else:            cur = self.__head            while cur.next is not None:                cur = cur.next            cur.next = node    def insert(self, pos, item):        """??????????"""        if pos <= 0:            self.add(item)        elif pos >= self.length():            self.append(item)        else:            pre = self.__head            count = 0            while count < pos - 1:                pre = pre.next                count += 1            node = Node(item)            node.next = pre.next            pre.next = node    def remove(self, item):        """??????"""        cur = self.__head        pre = None        while cur is not None:            if cur.elem == item:                if pre is None:                    self.__head = cur.next                else:                    pre.next = cur.next                break            pre = cur            cur = cur.next    def search(self, item):        """????????"""        cur = self.__head        while cur is not None:            if cur.elem == item:                return True            cur = cur.next        return False

4. ??????

????????????????

  • ???????????????????????
  • ????????????????????????????
  • ????????????????????????????

??????????????????????????

5. ????????

?????????????????

  • ????????????????????????????????????????????????
  • ???????????????????????????????????????
  • ????????????????????????????????????
  • ?????????????????????????????????????

    转载地址:http://pkto.baihongyu.com/

    你可能感兴趣的文章
    Qt笔记——QSemaphore处理生产者/消费者模式
    查看>>
    Qt笔记——QMutex&QWaitCondition处理生产者消费者模式
    查看>>
    Qt笔记——QLable+QPixmap图片缩放踩坑
    查看>>
    Qt笔记——foreach与forever
    查看>>
    QT程序怎么挪到Linux下,linux+Qt程序如何打包发布
    查看>>
    Qt知识:视图框架QGraphicsWidget详解
    查看>>
    SpringBoot中项目启动及定时任务缓存数据库常用数据至内存变量并转换后高频调用
    查看>>
    Qt知识: 画刷风格
    查看>>
    QT的OpenGL渲染窗QOpenGLWidget Class
    查看>>
    QT的C++程序加载动态链接库DLL(Linux下是so)的方式
    查看>>
    QT界面操作1:如何跟踪鼠标位置?
    查看>>
    Qt环境搭建(Visual Studio)
    查看>>
    QT点击"X"按钮,调用closeEvent()函数来实现调用特定事件(附:粗略介绍QT的信号与槽的使用方法)...
    查看>>
    QT样式表——url路径
    查看>>
    QT数据库(三):QSqlQuery使用
    查看>>
    QT教程5:消息框
    查看>>
    SpringBoot中集成阿里开源缓存访问框架JetCache实现声明式实例和方法缓存
    查看>>
    pom.xml中提示web.xml is missing and <failonmissingw>...
    查看>>
    Pomelo开发中Web客户端开发API简介
    查看>>
    QT教程2:QT5的体系构架
    查看>>