博客
关于我
数据结构第三天
阅读量: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/

    你可能感兴趣的文章
    OpenCV中基于已知相机方向的透视变形
    查看>>
    OpenCV中的监督学习
    查看>>
    opencv中读写视频
    查看>>
    OpenCV中遇到Microsoft C++ 异常 cv::Exception
    查看>>
    opencv之cv2.findContours和drawContours(python)
    查看>>
    opencv之namedWindow,imshow出现两个窗口
    查看>>
    opencv之模糊处理
    查看>>
    Opencv介绍及opencv3.0在 vs2010上的配置
    查看>>
    OpenCV使用霍夫变换检测图像中的形状
    查看>>
    opencv保存图片路径包含中文乱码解决方案
    查看>>
    OpenCV保证输入图像为三通道
    查看>>
    OpenCV入门教程(非常详细)从零基础入门到精通,看完这一篇就够了
    查看>>
    opencv图像分割2-GMM
    查看>>
    opencv图像分割3-分水岭方法
    查看>>
    opencv图像切割1-KMeans方法
    查看>>
    OpenCV图像处理篇之阈值操作函数
    查看>>
    opencv图像特征融合-seamlessClone
    查看>>
    OpenCV图像的深浅拷贝
    查看>>
    OpenCV在Google Colboratory中不起作用
    查看>>
    OpenCV学习(13) 细化算法(1)(转)
    查看>>