CP 164 Data Structures _ test_Sorts_array.py. [Tests various array-based sorting functions.]
CP 164 Data Structures _ test_Sorts_. [Tests various array-based sorting functions.] [Tests various array-based sorting functions.] ----------------------------------------------------------- ------------- Author: Jashanpreet Pannu ID: Email: __updated__ = "" ------------------------------------------------------------------------ """ # Imports import random from Number import Number from Sorts_array import Sorts # Constants SIZE = 100 # Size of array to sort. XRANGE = 1000 # Range of values in random arrays to sort. TESTS = 100 # Number of random arrays to generate. SORTS = ( ('Bubble Sort', Se_sort), ('Insertion Sort', Stion_sort), ('Merge Sort', S_sort), ('Quick Sort', S_sort), ('Selection Sort', Stion_sort), ('Bin. Ins. Sort', Sy_insert_sort), ('BST Sort', S_sort), ('Cocktail Sort', Sail_sort), ('Comb Sort', S_sort), ('Heap Sort', S_sort), ('Shell Sort', S_sort) ) def create_sorted(): """ ------------------------------------------------------- Creates a sorted list of SIZE Number objects with values from 0 up to SIZE-1. Use: values = create_sorted() ------------------------------------------------------- Returns: values - a sorted list of SIZE Number objects (list of Number) ------------------------------------------------------- """ values = [] i = 0 while i SIZE: d(Number(i)) i += 1 return values def create_reversed(): """ ------------------------------------------------------- Create a reversed list of SIZE Number objects with values from SIZE-1 down to 0. Use: values = create_reversed() ------------------------------------------------------- Returns:
Written for
- Institution
- CP 164 Data Structures _ test_Sorts_array.py.
- Course
- CP 164 Data Structures _ test_Sorts_array.py.
Document information
- Uploaded on
- April 11, 2023
- Number of pages
- 3
- Written in
- 2022/2023
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
cp 164 data structures testsortsarraypy tests various array based sorting functions