Victor OSTERTAG and Alejandro RUIZ RODRIGUEZ
Friday 20th of September 2017
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ
Cranfield University
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ
Cranfield University
Sort a sequence of integers
Return an array with the
sorted values
Our client
I'm not sure about
the size...
If you could give me an
array with the new values,
that'd be great!
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ
Cranfield University
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ
Cranfield University
Bubble
Insertion
SPEED
Insertion
SPACE
Tie
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ
Cranfield University
Radix sort is far from ideal
We eliminate it from the options
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ
Cranfield University
SPEED
Quick Sort
SPACE
Heap Sort
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ
Cranfield University
Safest choice
Better worst-case speed
Better space complexity
Okay average speed
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ
Cranfield University
As expected, < 30 elements, insertion sort is a bit better
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ
Cranfield University
Coded in Python
Pair programming
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ
Cranfield University
Many kinds of inputs:
[12, 15, 9, 5, 6, 75]
"5, 8, 9, 7, 9"
File
Command Line
Array & String
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ
Cranfield University
Easy to understand error messages:
Easy to use
from Sorter import Sorter
sorter = Sorter("4,5,8,9,6")
sorter.sort()
print(sorter.getToSort())
print(sorter.getSorted())
print(sorter.getNewPositions())
class Input:
Members:
array // Array created with the user's input
Methods:
void Constructor // Constructor
void checkString // Check if the string is usable
void checkArray // Check if the array is usable
int[] getArray // Get the array
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ
Cranfield University
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ
Cranfield University
class Sorter:
Members:
toSort // Initial array given by user
sorted // Sorted initial array
newPositions // Auxiliary and optional array
Methods:
void Constructor // Constructor
void heapSort // Sort the initial array
void insertionSort // Sort the initial array
void sort // Use the best sorting algorithm for the situation
void moveDown // Auxiliary function
void swap // Auxiliary function
int[] Getters // Get the array you want
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ
Cranfield University
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ
Cranfield University
Tons of different types of arrays
only zeros
Small size
Big size
Only negatives
Medium size
Test the sorting for
each functions
Test if the auxiliary
array is correct
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ
Cranfield University
Testing each possible input
Testing each possible wrong input
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ
Cranfield University
1,000 random arrays
(size 1 to 1,000)
1,000 random arrays
(size 10,000 to 11,000)
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ
Cranfield University
They liked it!
(The design, the factorisation, ...)
Would like more documentation
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ
Cranfield University
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ
Cranfield University
Good results
Requirements respected
including the
optional part
Structure and algorithms could be improved