Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Readme
The data structure and its operations are described Cormen et al. (chapter 19) Fibonacci heap supports mergeable-heap operations, including make-heap, insert, minimum, extract-min, and union. The data structure also supports key-decrease and delete, although using these two operations requires users to create nodes for items themselves.
Each node has the following attributes:
A heap has the following attributes:
Runs in worst-case time. Initializes an empty heap.
Runs in worst-case time. Adds the node as a root of the heap.
Runs in worst-case time. Returns the min attribute of the heap.
Runs in amortized time. Removes and returns the minimum node. This procedure moves each of the minimum node’s children to the root list, removes the minimum node itself from the root list, and consolidates the resulted tree to reduces the number of trees.
Runs in worst-case time. Makes and returns a union of two heaps. This procedure simply concatenates the two root lists.
Runs in amortized time. Decreases node x’s key to k.
Runs in amortized time. Remove x from the heap by first setting its key to minus infinity and extracting the heap’s min.
Installing using pip:
>>> pip install fibheap
Using mergable-heap operations:
>>> from fibheap import *
>>> heap1 = makefheap()
>>> heap2 = makefheap()
>>> num_list1 = [1,4,2]
>>> num_list2 = [6,-1,0]
>>> for num in num_list1:
... fheappush(heap1, num)
...
>>> for num in num_list2:
... fheappush(heap2, num)
...
>>> fheapunion(heap1, heap2)
>>> getfheapmin(heap1)
-1
>>> sorted_list = []
>>> while heap1.num_nodes:
... sorted_list.append(fheappop(heap1))
...
>>> sorted_list
[-1, 0, 1, 2, 4, 6]
When data contains more than numbers:
>>> item_list = [(3, 'a'),(0, 'z'), (2,'m'), (-2, 'r')]
>>> heap = makefheap()
>>> for item in item_list:
... fheappush(heap, item)
...
>>> sorted_list = []
>>> while heap.num_nodes:
... sorted_list.append(fheappop(heap))
...
>>> sorted_list
[(-2, 'r'), (0, 'z'), (2, 'm'), (3, 'a')]
FAQs
An implementation of Fibonacci heap
We found that fibheap demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.