Giter VIP home page Giter VIP logo

coding-note's Issues

problem about selection sort

陈老师:
您好!感谢您开源如此优秀的项目。
关于选择排序,我觉得在将min_index初始化为待排序数列的第1个元素后,不用再将array[min_index]与array[i]进行比较,因此我认为第二个for循环应该修改为for j in range(i+1, lengths);请问我的理解是否有误呢?请多多指教,谢谢!
def SelectionSort(array):
lengths = len(array)
for i in range(lengths-1):
min_index = i
for j in range(i+1, lengths):
if array[j] < array[min_index]:
min_index = j
array[i], array[min_index] = array[min_index], array[i]

return array

问雪

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.