Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pl3onasm committed Sep 15, 2024
1 parent c0c7241 commit 80a3d3b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Binary file modified algorithms/dynamic-programming/opt-bsts/images/obsts-test2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions datastructures/heaps/fibheaps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ $\huge{\color{Cadetblue}\text{Fibonacci heaps}}$

<br/>

This data structure comes in two flavors: a ${\color{peru}\text{min-heap}}$ or a ${\color{peru}\text{max-heap}}$. It is also called a ${\color{peru}\text{mergeable heap}}$, meaning that it supports the union operation, which merges two heaps into one. The Fibonacci heap is a collection (or forest) of rooted trees, placed in a circular doubly linked list. Each of these trees is a min-heap or a max-heap, depending on the flavor of the Fibonacci heap, and their roots are pointers to the minimum or maximum element in the tree. The Fibonacci heap is also a ${\color{peru}\text{lazy data structure}}$, meaning that it does not always maintain the heap property, but only does so when necessary. This allows for faster operations, but also makes the Fibonacci heap more complex than other heap data structures.
Just like any other heap, the Fibonacci heap comes in two flavors: a ${\color{peru}\text{min-heap}}$ or a ${\color{peru}\text{max-heap}}$. It is also called a ${\color{peru}\text{mergeable heap}}$, meaning that it supports the union operation, which merges two heaps into one. The Fibonacci heap is a collection (or forest) of rooted trees, placed in a circular doubly linked list. Each of these trees is a min-heap or a max-heap, depending on the flavor of the Fibonacci heap, and their roots are pointers to the minimum or maximum element in the tree. The Fibonacci heap is also a ${\color{peru}\text{lazy data structure}}$, meaning that it does not always maintain the heap property, but only does so when necessary. This allows for faster operations, but also makes the Fibonacci heap more complex than other heap data structures.

<br/>

Expand All @@ -23,7 +23,7 @@ $\Large{\color{darkseagreen}\text{Complexity}}$

The mentioned complexities are ${\color{peru}\text{amortized}}$, i.e. the average time taken per operation over a sequence of operations. The Fibonacci heap is a data structure that supports the above operations in amortized constant time, except for the delete and pop operations, which take $\mathcal{O}(\log {n})$ time.

The given implementation uses a map to keep track of the nodes in the heap, acting as an interface between the heap and the user data and allowing for updating the keys of the nodes in constant time. This, however, also means that the union operation takes more than constant time, as it involves merging the maps of the two heaps, resulting in a time complexity of $\mathcal{O}(m)$, where $m$ is the number of nodes in the smaller-sized heap. This could be avoided by storing a handle to the heap in the user data but would make the implementation less practical or user-friendly.
The given implementation uses a map to keep track of the nodes in the heap, acting as an interface between the heap and the user data and allowing for updating the keys of the nodes in constant time. This, however, also means that the union operation takes more than constant time, as it involves merging the maps of the two heaps, resulting in a time complexity of $\mathcal{O}(m)$, where $m$ is the number of nodes in the smaller-sized heap. This could be avoided by storing a handle to the heap in the user data, thus eliminating the need for a map and making the union operation constant time, but would make the implementation less practical or user-friendly.

<br/>

Expand Down

0 comments on commit 80a3d3b

Please sign in to comment.