<jupyter_start><jupyter_text>Asignment 1* Implement the sorting algorithm you came up with in pseudocode with Python* Test the sorting algorithm with a list of 10, 100, 1000 random numbers and compare the result using the %time to time your code and submit your results in code comments<jupyter_code>## pseudocode
# for number in a list:
#     put the first number of the list into the new list
#     for other numbers in the list
#     compare it with every number in the new list,get it's index number
#     if it's larger than any number in the new list, put it on the index+1 position
def get_sort(l):
    newlist = []
    newlist.append(l[0])
    for i in range(1,len(l)):
        added = False
        for m in range(len(newlist)):
            if l[i] > newlist[m]:
                added = False
            if added == False:
                if l[i] <= newlist[m]:
                    newlist.insert(m,l[i])
                    added = True 
        if added == False:
            newlist.append(l[i])
    return newlist
test10 = [4,5,8,1,3,5,22,14,50,23]
%time get_sort(test10)
# CPU times: user 25 µs, sys: 0 ns, total: 25 µs
# Wall time: 28.1 µs
# Out[79]:
# [1, 3, 4, 5, 5, 8, 14, 22, 23, 50]
import random
# test100 = random.sample(range(1, 1000), 100)
# %time get_sort(test100)
# CPU times: user 997 µs, sys: 20 µs, total: 1.02 ms
# Wall time: 1.05 ms
# test1000 = random.sample(range(1, 10000), 1000)
# %time get_sort(test1000)
# CPU times: user 128 ms, sys: 3.59 ms, total: 131 ms
# Wall time: 170 ms
sorted10 = get_sort(test10)
sorted100 = get_sort(test100)
sorted1000 = get_sort(test1000)<jupyter_output><empty_output><jupyter_text>Assignment 2* Implement the search algorithm you came up with in pseudocode with Python* Test the search algorithm with a list of 10,100,1000 random numbers (sorted with your sorting algorithm) and compare the result using the %time to time your code and submit your results in code comments<jupyter_code>## pseudocode
# input a sorted list and a search term
#     get the length of the list
#     for each number in the range of length
#         if the index number of the list equals to the search term
#             print index
#             something = True
#         else 
#             something = False
#     if False
#         print the item is not found
def check_num(l,n):
    for i in range(len(l)):
#         print(l[i])
        found = False
        if l[i] == n:
            found = True
            return "The index of the number in the list is " + str(i)
    if not found:
        return "The number is not in the list."
%time check_num(sorted10,4)
# CPU times: user 7 µs, sys: 0 ns, total: 7 µs
# Wall time: 11.2 µs
# Out[122]:
# 'The index of the number in the list is 2'
%time check_num(sorted100,4)
# CPU times: user 20 µs, sys: 0 ns, total: 20 µs
# Wall time: 23.1 µs
# Out[123]:
# 'The number is not in the list.'
%time check_num(sorted1000,9987)
# CPU times: user 120 µs, sys: 0 ns, total: 120 µs
# Wall time: 123 µs
# Out[127]:
# 'The index of the number in the list is 998'<jupyter_output>CPU times: user 120 µs, sys: 0 ns, total: 120 µs
Wall time: 123 µs
{'fraction_non_alphanumeric': 0.09584664536741214, 'fraction_numerical': 0.06389776357827476, 'mean_word_length': 2.841717791411043, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '665699', 'license': 'MIT', 'n_tokens_mistral': 1191, 'n_tokens_neox': 1014, 'n_words': 438, 'path': 'homework/03 Search, list functions/homework/wang_zhizhou_3_1&2.ipynb', 'repo_name': 'barjacks/algorithms_mine', 'size': '3130'}