sledge-serverless-framework
sledge-serverless-framework copied to clipboard
Sledge heap removal takes O(n)
Currently in Sledge the MinHeap implementation with Priority Queue has the delete
API implemented with O(n) time complexity.
https://github.com/gwsystems/sledge-serverless-framework/blob/9778db645aeac6fa98979707e2afa54db72929e8/runtime/include/priority_queue.h#L369-L386
It can be reduced to O(logn) by keeping the new array elements' indices as within the struct properties and update it on every change. Sample from the composite codebase: https://github.com/gwsystems/composite/blob/fa9e07f6790bfb73fe8d043538a8e95b87ad5f90/src/components/lib/util/heap.c#L238
Particularly the index update function u()
is helpful:
https://github.com/gwsystems/composite/blob/loader/src/components/lib/util/heap.c#L289-L293