|
1 | 1 | # Day 5: Recursive Selection Sort
|
2 | 2 |
|
3 |
| -**Fork and then clone me!** |
| 3 | +## Learning Goals |
4 | 4 |
|
5 |
| -Sort an Array of numbers using selection sort. The selection sort algorithm sorts an array by repeatedly finding the minimum element (lowest value) in the input Array, and then putting it at the correct location in the sorted Array. |
| 5 | +- Solve algorithm problems using recursion |
6 | 6 |
|
7 |
| -Once you're done solving the problem, calculate the average run time and compare it to the average run time for the iterative version. |
| 7 | +## Instructions |
8 | 8 |
|
9 |
| -``` |
| 9 | +Sort an array of numbers using selection sort. The selection sort algorithm |
| 10 | +sorts an array by repeatedly finding the minimum element (lowest value) in the |
| 11 | +input array, and then putting it at the correct location in the sorted array. |
| 12 | + |
| 13 | +Once you're done solving the problem, calculate the average run time and compare |
| 14 | +it to the average run time for the iterative version. |
| 15 | + |
| 16 | +```txt |
10 | 17 | Input: [3, -1, 5, 2]
|
11 | 18 | Output: [-1, 2, 3, 5]
|
12 | 19 | ```
|
13 | 20 |
|
14 |
| -You may wish to convert your iterative solution to a recursive one. We've included our old solutions in Ruby and JavaScript below: |
| 21 | +You may wish to convert your iterative solution to a recursive one. We've |
| 22 | +included our old solutions in Ruby and JavaScript below: |
15 | 23 |
|
16 | 24 | ```ruby
|
17 | 25 | def selection_sort(arr)
|
@@ -44,9 +52,10 @@ function selectionSort(arr) {
|
44 | 52 | }
|
45 | 53 | ```
|
46 | 54 |
|
47 |
| -Use the language of your choosing. We've included starter files for some languages where you can pseudocode, explain your solution and code. |
| 55 | +Use the language of your choosing. We've included starter files for some |
| 56 | +languages where you can pseudocode, explain your solution and code. |
48 | 57 |
|
49 |
| -## Before you start coding: |
| 58 | +## Before you start coding |
50 | 59 |
|
51 | 60 | 1. Rewrite the problem in your own words
|
52 | 61 | 2. Validate that you understand the problem
|
|
0 commit comments