<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          Github標星86.4K+:常見數(shù)據(jù)結(jié)構(gòu)與算法的Python實現(xiàn)

          共 1915字,需瀏覽 4分鐘

           ·

          2020-10-24 00:58

          有人問我數(shù)據(jù)結(jié)構(gòu)與算法怎么學?

          免費的我推薦嚴蔚敏老師的數(shù)據(jù)結(jié)構(gòu)課程,網(wǎng)上可以查到,當年考博士時候?qū)W的就是這個。

          收費的我推薦王爭老師的《數(shù)據(jù)結(jié)構(gòu)與算法之美》,內(nèi)容挺全面,學了應該對算法有幫助。

          以上兩個教程都不是用python實現(xiàn)的,有群友問怎么用python實現(xiàn)常見的數(shù)據(jù)結(jié)構(gòu)算法?我找到一個github標星86.4k+star的倉庫,把各種常見算法用python實現(xiàn)了,而且還有動圖演示,非常值得推薦。(黃海廣)


          倉庫說明

          這個倉庫用python語言實現(xiàn)了絕大部分算法,主要是用于教學目的,因此效率稍微低于工業(yè)界。

          倉庫地址:

          https://github.com/TheAlgorithms/Python


          內(nèi)容說明


          包含了常見的算法的python實現(xiàn),如二叉樹、排序、查找等等。這些是算法工程師必須掌握的技能。

          文件目錄

          動畫演示

          冒泡排序



          桶排序


          快速排序

          典型代碼

          (這個是冒泡排序的代碼):

          from __future__ import print_function

          def bubble_sort(collection):
          ????"""Pure implementation of bubble sort algorithm in Python
          ????:param collection: some mutable ordered collection with heterogeneous
          ????comparable items inside
          ????:return: the same collection ordered by ascending
          ????Examples:
          ????>>> bubble_sort([0, 5, 3, 2, 2])
          ????[0, 2, 2, 3, 5]
          ????>>> bubble_sort([])
          ????[]
          ????>>> bubble_sort([-2, -5, -45])
          ????[-45, -5, -2]

          ????>>> bubble_sort([-23,0,6,-4,34])
          ????[-23,-4,0,6,34]
          """

          ????length = len(collection)
          ????for i in range(length-1):
          ????????swapped = False
          ????????for j in range(length-1-i):
          ????????????if collection[j] > collection[j+1]:
          ????????????????swapped = True
          ????????????????collection[j], collection[j+1] = collection[j+1], collection[j]
          ????????????if not swapped: break # Stop iteration if the collection is sorted.
          ????????return collection

          if __name__ == '__main__':
          ????try:
          ????????raw_input # Python 2
          ????except NameError:
          ????????raw_input = input # Python 3
          ????user_input = raw_input('Enter numbers separated by a comma:').strip()
          ????unsorted = [int(item) for item in user_input.split(',')]
          ????print(*bubble_sort(unsorted), sep=',')


          總結(jié)


          數(shù)據(jù)結(jié)構(gòu)與算法設(shè)計怎么學?

          免費的我推薦嚴蔚敏老師的數(shù)據(jù)結(jié)構(gòu)課程,網(wǎng)上可以查到,用c語言實現(xiàn),當年考博士時候?qū)W的就是這個。

          收費的我推薦極客時間的《數(shù)據(jù)結(jié)構(gòu)與算法之美》,內(nèi)容挺全面,學了應該對算法有很大幫助?!?/span>可以閱讀原文購買

          算法的python實現(xiàn)推薦github上一個86.4k+star的倉庫,把各種常見算法用Python實現(xiàn)了,而且還有動圖演示。

          倉庫地址:

          https://github.com/TheAlgorithms/Python



          瀏覽 41
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  av综合人妻 | 西西4444www大胆艺术 | 亚洲天堂在线播放 | 99性爱视频 | 日逼视频免费国产 |