Functions
rand_int_array
Generates an array of random integers.The number of integers to generate
The maximum number in the range (0 to maxnum inclusive)
Array of n random integers from 0 to maxnum
Example
filled_array
Generates a sorted array filled with integers from 0 to n-1.The number of integers to generate
Array filled with integers from 0 to n-1 in ascending order
Example
shuffle_array
Generates a shuffled array with integers from 0 to n-1.The number of integers to generate
Randomly shuffled array containing integers from 0 to n-1
Example
is_sorted
Checks if an array is sorted in ascending order.The array to verify
True if the array is sorted in ascending order, False otherwise
array_details
Returns a formatted string with array statistics.The array to analyze
String containing count of elements, first 10 elements, and last 10 elements
Example
generate_almost_sorted_array
Generates an almost sorted array with a specified number of random swaps.The size of the array to generate
The number of adjacent elements to swap to create disorder
Array of integers that is mostly sorted with specified local swaps
Use Cases for Sort Testing
Use Cases for Sort Testing
Performance Benchmarking:
- Use
rand_int_array()for average case testing - Use
filled_array()for best case testing (already sorted) - Use
shuffle_array()for worst case testing (completely random) - Use
generate_almost_sorted_array()for testing adaptive algorithms
- Use
is_sorted()to verify your sorting algorithm works correctly - Use
array_details()to inspect large arrays without printing all elements