Update insertion sort challenge (#137)

Update constraints and algorithm.
This commit is contained in:
Donne Martin 2017-01-13 20:02:24 -05:00 committed by GitHub
parent d6ae3fa785
commit d6da67c748
2 changed files with 11 additions and 4 deletions

View File

@ -34,7 +34,7 @@
"source": [ "source": [
"## Constraints\n", "## Constraints\n",
"\n", "\n",
"* Is a naiive solution sufficient?\n", "* Is a naive solution sufficient?\n",
" * Yes\n", " * Yes\n",
"* Are duplicates allowed?\n", "* Are duplicates allowed?\n",
" * Yes\n", " * Yes\n",

View File

@ -33,7 +33,7 @@
"source": [ "source": [
"## Constraints\n", "## Constraints\n",
"\n", "\n",
"* Is a naiive solution sufficient?\n", "* Is a naive solution sufficient?\n",
" * Yes\n", " * Yes\n",
"* Are duplicates allowed?\n", "* Are duplicates allowed?\n",
" * Yes\n", " * Yes\n",
@ -72,8 +72,15 @@
" * Break\n", " * Break\n",
"\n", "\n",
"Complexity:\n", "Complexity:\n",
"* Time: O(n^2) avarage, worst. O(1) best if input is already sorted.\n", "* Time: O(n^2) avarage, worst. O(1) best if input is already sorted\n",
"* Space: O(1), stable" "* Space: O(1) for the iterative solution\n",
"\n",
"Misc: \n",
"\n",
"* In-place\n",
"* Stable\n",
"\n",
"Insertion sort works well for very small datasets where most of the input is already sorted."
] ]
}, },
{ {