From c6abd4b2a1fc631319b1a7d2791e948d289c9ae0 Mon Sep 17 00:00:00 2001 From: julien lengrand-lambert Date: Thu, 5 Dec 2013 15:53:17 +0100 Subject: [PATCH] Starts working on the MergeSort algorithm --- 02_hash_maps/hm.py | 2 +- 03_MergeSort/ms.py | 28 ++++++++++++++++++++++++++++ 03_MergeSort/ms_test.py | 13 +++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 03_MergeSort/ms.py create mode 100644 03_MergeSort/ms_test.py diff --git a/02_hash_maps/hm.py b/02_hash_maps/hm.py index de316e9..7a7cc69 100644 --- a/02_hash_maps/hm.py +++ b/02_hash_maps/hm.py @@ -1,7 +1,7 @@ """ HashMap Table Implementation -Collisions are not handled in this version. +Collisions are handled in the neighbour and Table versions. @jlengrand 2013/11 diff --git a/03_MergeSort/ms.py b/03_MergeSort/ms.py new file mode 100644 index 0000000..5e16cbf --- /dev/null +++ b/03_MergeSort/ms.py @@ -0,0 +1,28 @@ +""" +Implementation of the MergeSort algorithm + +@jlengrand +2013/12 +""" + +class TableSorter(): + """ + A utili=ty that provides way to sort arrays of elements. + It should be possible to compare elements to each others + (meaning a > b and a == b should make sense). + """ + + #empty for now + def __init__(self): + pass + + def mergeSort(self, table, idx_min=1, idx_max=None): + """ + Returns the table array sorted between + indices idx_min and idx_max using the merge sort algorithm + """ + if idx_max == None: + idx_max = len(table) + + #TODO: Implement + return None diff --git a/03_MergeSort/ms_test.py b/03_MergeSort/ms_test.py new file mode 100644 index 0000000..9ed627f --- /dev/null +++ b/03_MergeSort/ms_test.py @@ -0,0 +1,13 @@ +""" +Unit Tests for the MergeSort implementation +@jlengrand +2013/12 +""" + +from ms import TableSorter + +import unittest + +class test_table_sorter(unittest.TestCase): + + #TODO: Implement \ No newline at end of file