I compare the effectiveness of bubble sorting and merge sorting methods, applying to a linked list.
In the input file input.txt
there is a long non-negative integer written on each line
(the maximum length of the number is 100 characters).
- Read the given numbers as a singly linked list data structure
- Return the given numbers in non-decreasing order.
Extra:
- Hide data members in Node. Return by methods or properties;
- Implement the LinkedList class with the methods: append, find, remove, insert, swap;
- Try to do it through merge sort and bubble sort. Measure the time of each method.
🚫 You cannot use built-in python types: list, all
In the input file input.txt
you may specify any array that meets the requirement of the task.
To run the script you need to call:
def runtime_test(sort_method, elements)
specifying as parameters the desired sorting method and an array of numbers from input.txt
.
It will return the average runtime result for 1 000 000 calls.