<jupyter_start><jupyter_text>**Sorting Algorithms and codes written in python**This notebook have all the commonly used sorting algorithms used in programming . All these algo's are written in python language. INPUT DATA  `input_list = [ 8, 2, 5, 1, 0, 2, 2, 4, 1, 10, 9]`  `sorted_list = [ 0, 1, 1, 2, 2, 2, 4, 5, 8, 9, 10]` Using the functions  __sorted_list__ = __name_of_sorting__( __list_to_be_sorted__ )  eg:         `sorted_list = insertion_sort( list )`  1. Implements the Insertion Sort in python<jupyter_code>def insertion_sort(list):
  for index in range(1,len(list)):
    value = list[index]
    i = index -1
    while i >=0:
      if value < list[i]:
        list[i+1] = list[i]
        list[i] = value
        i = i -1
      else:
        break
  return list<jupyter_output><empty_output><jupyter_text>2.Implements the Selection Sort in python<jupyter_code>def selection_sort(list):
  for i in range(len(list)):
    min_pos = i
    for j in range(i,len(list)):
      if list[j]< list[min_pos]:
        min_pos = j
    
    list[i],list[min_pos]=list[min_pos],list[i]

  return list<jupyter_output><empty_output><jupyter_text>3. Implements the Bubble Sort in python<jupyter_code>#solution<jupyter_output><empty_output><jupyter_text>4.Implements the Quick Sort in python<jupyter_code>def quick_sort(list):
  from random import randint

  if len(list) <=1:
    return list

  pivot = list[randint(0,len(list)-1)]

  smaller,equal,larger = [],[],[]

  for value in list:
    if value < pivot: smaller.append(value)
    elif value == pivot:  equal.append(value)
    else: larger.append(value)

  return quick_sort(smaller)+equal+quick_sort(larger)<jupyter_output><empty_output><jupyter_text>5.Implements the Merge Sort in python<jupyter_code>def merge_sort(arr):
  if len(arr) <=1:
    return arr
  
  mid_post = len(arr) // 2

  left_array , right_array = merge_sort(arr[:mid_point]), merge_sort(arr[mid_point:])

  return merge(left_array,right_array)

def merge(left,right):
  result = []
  #i - left_index    j - right_index
  i = j = 0

  if left[i] < right[j]:
    result.append(left[i])
    i += 1
  elif left[i] == right [j]:
    result.append(right[j])
    j += 1
  else:
    result.append(left[i])
    result.append(right[j])

    i += 1
    j += 1
  
  result.extend(left[i:])
  result.extend(right[j:])

  return result<jupyter_output><empty_output><jupyter_text>6. Implements the Count Sort in python<jupyter_code>#solution<jupyter_output><empty_output><jupyter_text>7.Implements the Bucket Sort in python<jupyter_code>#solution<jupyter_output><empty_output><jupyter_text>8.Implements the Radix Sort in python<jupyter_code>#solution<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12481371087928465, 'fraction_numerical': 0.01751117734724292, 'mean_word_length': 4.223735408560311, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 34, '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': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '129446', 'license': 'MIT', 'n_tokens_mistral': 1034, 'n_tokens_neox': 983, 'n_words': 230, 'path': 'Sorting/Sorting_codes.ipynb', 'repo_name': 'FAHADPN/Python-overflow', 'size': '2684'}