Sorting Library

Victor OSTERTAG and Alejandro RUIZ RODRIGUEZ
Friday 20th of September 2017
Plan

Sorting Library
OSTERTAG and RUIZ RODRIGUEZ

Comparing the algorithms
Designing the library
Testing the library
Conclusion



Cranfield University
Intro
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!



Comparing
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ

Cranfield University
Insertion VS Bubble
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ

Cranfield University



Bubble
Insertion
SPEED

Insertion




SPACE
Tie

The rest
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ

Cranfield University

Radix sort is far from ideal

We eliminate it from the options

The rest
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ

Cranfield University
SPEED

Quick Sort



SPACE
Heap Sort


Final choice
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ

Cranfield University

Heap Sort
Safest choice
Better worst-case speed
Better space complexity
Okay average speed
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ

Cranfield University
Insertion VS Heap



As expected, < 30 elements, insertion sort is a bit better
Designing

Working environment
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ

Cranfield University


Coded in Python
Pair programming

User friendly
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
User friendly
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
Input Class
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
Sorter Class
Tests
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ

Cranfield University

Functionality Test
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
Input test
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ

Cranfield University

Testing each possible input
Testing each possible wrong input
Performance test
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)
Code Review
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ

Cranfield University

They liked it!

(The design, the factorisation, ...)
BUT
Would like more documentation

Conclusion
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ

Cranfield University
Conclusion
Sorting Library
OSTERTAG and RUIZ RODRIGUEZ

Cranfield University
Good results

Requirements respected


including the
optional part
Structure and algorithms could be improved
Sorting Library
By isvoli
Sorting Library
- 844