-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Raj Patil <rajp152k@gmail.com>
- Loading branch information
Showing
13 changed files
with
200 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
:PROPERTIES: | ||
:ID: ce5570cd-e6c4-4dcc-9146-860cbb11a15d | ||
:END: | ||
#+title: Array | ||
#+filetags: :data:cs: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
:PROPERTIES: | ||
:ID: 198d0435-df28-4af5-a687-3475ed78eadf | ||
:ROAM_ALIASES: "Priority Queue" | ||
:END: | ||
#+title: Heap | ||
#+filetags: :data:cs: | ||
|
||
* Overview | ||
|
||
- *Definition*: A heap is a specialized [[id:3821a4f5-998a-4903-970f-d95bf2ed8cd4][tree]]-based data structure that satisfies the heap property as described below: | ||
|
||
- *Types*: | ||
- *Max-Heap*: The parent node has a value greater than or equal to its children. | ||
- *Min-Heap*: The parent node has a value less than or equal to its children. | ||
|
||
- *Common Implementations*: | ||
- *[[id:5ed05b89-71e5-423c-b51c-dc53133c3e91][Binary Heap]]*: Most common heap implementation which uses a complete binary tree structure. | ||
- *[[id:a1958360-5d36-4994-a617-37c040f78812][Fibonacci Heap]]*: More advanced, allowing for more efficient merge operations. | ||
- *[[id:addc4776-3f73-47a6-94b7-9cd9dd07b996][Binomial Heap]]*: Amalgamates multiple [[id:e7006647-efb9-4fce-8b3a-3bf6fabac685][binomial trees]] for optimized operations. | ||
|
||
- *Operations*: | ||
- *Insertion*: Adding a new element while maintaining the heap property. | ||
- *Deletion*: Typically removing the root (max or min), followed by reorganizing to maintain heap integrity. | ||
- *Peek*: Accessing the root element without modifying the heap. | ||
|
||
- *Applications*: | ||
- *Priority Queues*: Heaps are commonly used to implement priority queues. | ||
- *Heap Sort*: An efficient sorting algorithm that utilizes a heap. | ||
- *Graph Algorithms*: Utilized in algorithms like Dijkstra's shortest path. | ||
|
||
- *Time Complexity*: | ||
- Insertion: O(log n) | ||
- Deletion (removing root): O(log n) | ||
- Accessing the root: O(1) | ||
- Building a heap: O(n) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
:PROPERTIES: | ||
:ID: 5ed05b89-71e5-423c-b51c-dc53133c3e91 | ||
:END: | ||
#+title: Binary Heap | ||
#+filetags: :data:cs: | ||
|
||
* Key Properties and Characteristics | ||
|
||
- *Definition*: A binary heap is a complete [[id:3821a4f5-998a-4903-970f-d95bf2ed8cd4][binary tree]] that satisfies the [[id:198d0435-df28-4af5-a687-3475ed78eadf][heap]] property. | ||
- *Heap Property*: | ||
- *Max-Heap*: The key of each node is greater than or equal to the keys of its children. The maximum key is at the root. | ||
- *Min-Heap*: The key of each node is less than or equal to the keys of its children. The minimum key is at the root. | ||
|
||
- *Structure*: | ||
- Complete binary trees, meaning all levels are fully filled, except possibly for the last level. | ||
- Efficiently stored in array format, where for a node at index =i=: | ||
- Left child: =2*i + 1= | ||
- Right child: =2*i + 2= | ||
- Parent: =floor((i - 1) / 2)= | ||
|
||
- *Time Complexity*: | ||
- Insertion: O(log n) | ||
- Deletion: O(log n) | ||
- Find-min or Find-max: O(1) | ||
- Building a heap: O(n) | ||
|
||
- *Applications*: | ||
- Priority Queues: Efficiently manage dynamically changing priority data. | ||
- [[id:4a362cc7-3fe3-46b5-9038-c0e5d4af2eb5][Heapsort]]: An efficient sorting algorithm using binary heaps. | ||
- [[id:1d703f5b-8b5e-4c82-9393-a2c88294c959][Graph]] algorithms: Such as [[id:e31f91e8-25d9-499b-9c55-10afcb086edb][Dijkstra]]’s and [[id:dd72e849-016c-4065-80fd-656fad075d4a][Prim]]’s for [[id:eeca3654-8525-4ce3-a135-a51e262094c3][minimum spanning trees]]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
:PROPERTIES: | ||
:ID: 4a362cc7-3fe3-46b5-9038-c0e5d4af2eb5 | ||
:END: | ||
#+title: Heapsort | ||
#+filetags: :algo:cs: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
:PROPERTIES: | ||
:ID: e31f91e8-25d9-499b-9c55-10afcb086edb | ||
:END: | ||
#+title: Dijkstra's Algorithm | ||
#+filetags: :algo:cs: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
:PROPERTIES: | ||
:ID: dd72e849-016c-4065-80fd-656fad075d4a | ||
:END: | ||
#+title: Prim's Algorithm | ||
#+filetags: :algo:cs: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
:PROPERTIES: | ||
:ID: eeca3654-8525-4ce3-a135-a51e262094c3 | ||
:END: | ||
#+title: minimum spanning trees | ||
#+filetags: :data:cs: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
:PROPERTIES: | ||
:ID: a1958360-5d36-4994-a617-37c040f78812 | ||
:END: | ||
#+title: Fibonacci Heap | ||
#+filetags: :data:cs: | ||
|
||
* Overview | ||
- *Definition*: | ||
- A Fibonacci [[id:198d0435-df28-4af5-a687-3475ed78eadf][heap]] is a type of data structure that consists of a collection of trees following the properties of a min-heap (or max-heap). It allows for very efficient merging of heaps and is used in [[id:dd94cae5-96e2-4a46-9890-41c8c88059bc][network optimization algorithms]]. | ||
|
||
- *Structure*: | ||
- The Fibonacci heap is composed of a collection of heap-ordered trees, structured in such a way that the minimum element is always accessible. | ||
- Nodes within the trees can hold more than one child, forming a Fibonacci-like structure, hence the name. | ||
|
||
- *Key Operations*: | ||
- *Insertion*: Adds a new element to the heap in constant time, O(1). | ||
- *Finding Minimum*: Provides access to the minimum element in O(1) time. | ||
- *Union*: Merges two heaps in O(1) time; this is one of the highlights of Fibonacci heaps. | ||
- *Decrease Key*: Decreases the key of a node, which takes [[id:b91e378d-b17a-43b2-b13e-19c02afe1558][amortized]] O(1) time. | ||
- *Delete*: Removal of the minimum element within O(log n) time. | ||
|
||
- *Applications*: | ||
- Primarily used in graph algorithms such as [[id:e31f91e8-25d9-499b-9c55-10afcb086edb][Dijkstra's]] and [[id:dd72e849-016c-4065-80fd-656fad075d4a][Prim's]] algorithms, where efficient priority queue operations are paramount. | ||
- Useful in scenarios where merge operations are frequent and optimized performance over several operations is needed. | ||
|
||
* Operational Breakdown and Explanation | ||
|
||
- Amortized Analysis: | ||
- Fibonacci heaps leverage amortized analysis to ensure that while individual operations may seem costly, the average time per operation over a sequence of operations is efficient. | ||
- This is particularly relevant for operations like decrease key and delete. | ||
|
||
- Operational Complexity: | ||
- *Insert*: O(1) - This operation simply adds the new element to the list of roots. | ||
- *Find Minimum*: O(1) - Constant time access to the minimum element. | ||
- *Union*: O(1) - Combining the root lists of two Fibonacci heaps. | ||
- *Decrease Key*: O(1) amortized - The node is cut from its parent and added to the root list; potential restructuring happens lazily. | ||
- *Delete*: O(log n) - Involves decreasing the key to negative infinity followed by removing the minimum element. | ||
|
||
- Heuristic Characteristics: | ||
- Lazy Merging: Allows for efficient merging of heaps and defers the restructuring to later operations. | ||
- Tree Structure: Each tree is a min-heap, which guarantees that the minimum element is always accessible. | ||
|
||
* Resources | ||
- https://en.wikipedia.org/wiki/Fibonacci_heap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
:PROPERTIES: | ||
:ID: dd94cae5-96e2-4a46-9890-41c8c88059bc | ||
:END: | ||
#+title: network optimization | ||
#+filetags: :network:cs: | ||
|
||
* Resources | ||
- https://networkoptimization.dev/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
:PROPERTIES: | ||
:ID: addc4776-3f73-47a6-94b7-9cd9dd07b996 | ||
:END: | ||
#+title: Binomial Heap | ||
#+filetags: :data:cs: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
:PROPERTIES: | ||
:ID: e7006647-efb9-4fce-8b3a-3bf6fabac685 | ||
:END: | ||
#+title: binomial trees | ||
#+filetags: :data:cs: | ||
|
||
|
||
* Overview | ||
|
||
- *Definition of Binomial Trees*: | ||
- A binomial tree is a data structure that is a recursive combination of binomial trees, each representing a set of potential states or values at each node. | ||
|
||
- *Structure*: | ||
- A binomial tree of order \( k \) consists of \( 2^k \) nodes. | ||
- Each node has \( k \) children, corresponding to the structure of the binomial coefficient. | ||
|
||
- *Properties*: | ||
- The height of a binomial tree of order \( k \) is \( k \). | ||
- There are \( C(k, i) \) ways to choose \( i \) children from \( k \). | ||
|
||
- *Operations*: | ||
- *Merge*: Merging two binomial trees is efficient, \( O(\log n) \). | ||
- *Insert*: Inserting a new element is also \( O(\log n) \). | ||
- *Delete*: Deletion can be done in logarithmic time as well. | ||
|
||
- *Applications*: | ||
- Commonly used in the implementation of priority queues, particularly in [[id:a1958360-5d36-4994-a617-37c040f78812][Fibonacci heaps]]. | ||
- Useful in algorithms for binomial queues and efficient algorithms in [[id:dd94cae5-96e2-4a46-9890-41c8c88059bc][network design]]. | ||
|
||
* Resources | ||
- https://en.wikipedia.org/wiki/Binomial_heap |