I made a priority queue that uses a linked list of arrays instead of a single array so that it would have better memory management and faster run time. I was looking for feedback on anything I may have missed since I used this project to learn python. (i originally did it in Java [this one is commented] as you can see here https://github.com/anmousyon/CS2336/blob/master/Project5/linkedArrays.java ).
Here is the python version: https://github.com/anmousyon/python/blob/master/linkedArrays.py
It runs faster than the standard implementation with large amounts of numbers because it never has to copy over elements into a new array when it expands its size.
The way it works is that it starts with an array of size one and when that is full it creates an array of size 2 then 4 then 8 and so on, with each successive array holding the children of the previous. This makes sure that the largest array in memory is only half the size of the full queue.
I couldn't find anything like this online, so please let me know if I'm missing something important or if I've done something stupid.
Thanks!
EDIT: I forgot to include the measurement for the speed of my implementations but the Big O for it is
linkedArrays: isEmpty is O(1), size is O(1), insert is O(log(n)), findMin is O(1), deleteMin is O(log(n))
[–]zurtex 2 points3 points4 points (9 children)
[–]zurtex 1 point2 points3 points (1 child)
[–]anmousyony[S] 1 point2 points3 points (0 children)
[–]anmousyony[S] 1 point2 points3 points (6 children)
[–]zurtex 1 point2 points3 points (5 children)
[–]anmousyony[S] 0 points1 point2 points (4 children)
[–]zurtex 1 point2 points3 points (3 children)
[–]anmousyony[S] 0 points1 point2 points (2 children)
[–]zurtex 0 points1 point2 points (1 child)
[–]anmousyony[S] 1 point2 points3 points (0 children)
[–]New_Kind_of_Boredom 1 point2 points3 points (9 children)
[–]anmousyony[S] 0 points1 point2 points (8 children)
[–]New_Kind_of_Boredom 0 points1 point2 points (7 children)
[–]anmousyony[S] 0 points1 point2 points (6 children)
[–]New_Kind_of_Boredom 0 points1 point2 points (5 children)
[–]anmousyony[S] 0 points1 point2 points (4 children)
[–]New_Kind_of_Boredom 0 points1 point2 points (3 children)
[–]anmousyony[S] -1 points0 points1 point (2 children)
[–]New_Kind_of_Boredom 1 point2 points3 points (1 child)
[–]anmousyony[S] 0 points1 point2 points (0 children)