sorts.iterative_merge_sort¶
Implementation of iterative merge sort in Python Author: Aman Gupta
For doctests run following command: python3 -m doctest -v iterative_merge_sort.py
For manual testing run: python3 iterative_merge_sort.py
Attributes¶
Functions¶
|
Return a sorted copy of the input list |
|
sorting left-half and right-half individually |
Module Contents¶
- sorts.iterative_merge_sort.iter_merge_sort(input_list: list) list ¶
Return a sorted copy of the input list
>>> iter_merge_sort([5, 9, 8, 7, 1, 2, 7]) [1, 2, 5, 7, 7, 8, 9] >>> iter_merge_sort([1]) [1] >>> iter_merge_sort([2, 1]) [1, 2] >>> iter_merge_sort([2, 1, 3]) [1, 2, 3] >>> iter_merge_sort([4, 3, 2, 1]) [1, 2, 3, 4] >>> iter_merge_sort([5, 4, 3, 2, 1]) [1, 2, 3, 4, 5] >>> iter_merge_sort(['c', 'b', 'a']) ['a', 'b', 'c'] >>> iter_merge_sort([0.3, 0.2, 0.1]) [0.1, 0.2, 0.3] >>> iter_merge_sort(['dep', 'dang', 'trai']) ['dang', 'dep', 'trai'] >>> iter_merge_sort([6]) [6] >>> iter_merge_sort([]) [] >>> iter_merge_sort([-2, -9, -1, -4]) [-9, -4, -2, -1] >>> iter_merge_sort([1.1, 1, 0.0, -1, -1.1]) [-1.1, -1, 0.0, 1, 1.1] >>> iter_merge_sort(['c', 'b', 'a']) ['a', 'b', 'c'] >>> iter_merge_sort('cba') ['a', 'b', 'c']
- sorts.iterative_merge_sort.merge(input_list: list, low: int, mid: int, high: int) list ¶
sorting left-half and right-half individually then merging them into result
- sorts.iterative_merge_sort.user_input¶