<jupyter_start><jupyter_text>Homework (12 pts) - Algorithms <NAME> nd8288Questions below refer to the **Selection Sort** algorithm. See image depiction below.![Selection Sort](images/selectionsort.jpg) 1. (3 pts) Write a breif high level natural language description of how you would implement the selection sort algorithm.<jupyter_code>Start at index 0 (first element in array). Go through the entire array and find the smallest element. Swap it with the first element at index 0.

Start at index 1 (second element in array). Go through the entire array and find the second-smallest element. Swap it with the second element at index 1.

Starting at index 2, find the third-smallest element. Swap it with the third element in the list at index 2.

Repeat finding the next-smallest element, and swapping it into the correct position until the array is sorted.<jupyter_output><empty_output><jupyter_text>2. (3 pts) Write pseudocode for the selection sort algorithm.<jupyter_code>define and name function (with parameters):
    
    for loop to go through each index in the length of list
        find the min
            start with min = first element
        go through array and see if there is a smaller value than current index
        swap the min with the smaller element at that index

    return items<jupyter_output><empty_output><jupyter_text>3. (3 pts) Write a function implementing the selection sort algorithm on an input list.<jupyter_code>def selectionSort(items):
    for i in range (len(items) - 1):
        # find the min
        min = items[i]
        min_Idx = i
        
        for n in range (i + 1, len(items)):
            if (items[n] < min):
                min = items[n]
                min_Idx = n
                
        # Swap the min with the element at the ith place
        items[min_Idx] = items[i]
        items[i] = min
    return items<jupyter_output><empty_output><jupyter_text>4. (3 pts) Use your function to sort the list of items below. Print your sorted items to verify.<jupyter_code>import numpy as np

items = np.random.randint(0, 10, 20)

print("Original:", items)
print("Sorted:", selectionSort(items))<jupyter_output>Original: [4 9 6 6 0 2 7 6 3 3 1 7 9 4 6 3 8 3 7 4]
Sorted: [0 1 2 3 3 3 3 4 4 4 6 6 6 6 7 7 7 8 9 9]
{'fraction_non_alphanumeric': 0.06884377758164166, 'fraction_numerical': 0.029567519858781994, 'mean_word_length': 3.136861313868613, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '129432', 'license': 'Unlicense', 'n_tokens_mistral': 709, 'n_tokens_neox': 648, 'n_words': 316, 'path': 'homework/homework-algorithms.ipynb', 'repo_name': 'nishadalal120/NEU-365P-385L-Spring-2021', 'size': '2271'}