Changes
Jump to navigation
Jump to search
← Older edit
Newer edit →
Algorithms
(view source)
Revision as of 22:20, 12 December 2016
11 bytes added
,
22:20, 12 December 2016
no edit summary
Line 19:
Line 19:
'''Python Code'''
'''Python Code'''
−
---
+
-
---
def insertionSort(alist):
def insertionSort(alist):
−
:for index in range(1,len(alist)):
+
:for index in range(1,len(alist)):
−
+
: :currentvalue = alist[index]
−
::currentvalue = alist[index]
+
: :position = index
−
::position = index
+
: :while position>0 and alist[position-1]>currentvalue:
−
+
: : :alist[position]=alist[position-1]
−
::while position>0 and alist[position-1]>currentvalue:
+
: : :position = position-1
−
:::alist[position]=alist[position-1]
+
: :alist[position]=currentvalue
−
:::position = position-1
−
−
::alist[position]=currentvalue
alist = [54,26,93,17,77,31,44,55,20]
alist = [54,26,93,17,77,31,44,55,20]
Marialchemist
83
edits
Cookies help us deliver our services. By using our services, you agree to our use of cookies.
More information
OK
Navigation menu
Personal tools
English
Log in
Request account
Namespaces
Page
Discussion
Variants
Views
Read
View source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
Special pages
Printable version