Added selection sort animation. Added question about allowing duplicate values.

This commit is contained in:
Donne Martin 2015-05-27 07:13:28 -04:00
parent d909f7bfdf
commit e2852c7ca6

View File

@ -22,6 +22,8 @@
"* Are we sorting integers?\n", "* Are we sorting integers?\n",
" * Yes\n", " * Yes\n",
"* Can we assume the input is valid integers?\n", "* Can we assume the input is valid integers?\n",
" * Yes\n",
"* Can we have duplicate integers?\n",
" * Yes" " * Yes"
] ]
}, },
@ -42,6 +44,9 @@
"source": [ "source": [
"## Algorithm\n", "## Algorithm\n",
"\n", "\n",
"Wikipedia's animation:\n",
"![alt text](http://upload.wikimedia.org/wikipedia/commons/9/94/Selection-Sort-Animation.gif)\n",
"\n",
"We can do this recursively or iteratively. Iteratively will be more efficient as it doesn't require the extra space overhead with the recursive calls.\n", "We can do this recursively or iteratively. Iteratively will be more efficient as it doesn't require the extra space overhead with the recursive calls.\n",
"\n", "\n",
"* For each element\n", "* For each element\n",