mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
Update insertion sort challenge (#137)
Update constraints and algorithm.
This commit is contained in:
parent
d6ae3fa785
commit
d6da67c748
|
@ -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",
|
||||||
|
|
|
@ -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."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user