|
1 |
| -# :chart_with_upwards_trend: Data Structure : Tries Concepts |
| 1 | +# :chart_with_upwards_trend: Data Structure : Trees Concepts |
2 | 2 |
|
3 | 3 | ##### Tries
|
4 | 4 |
|
@@ -344,3 +344,21 @@ It is a powerful data structure used in various string operations like pattern m
|
344 | 344 | - Uniqueness of Internal Nodes: Every internal node, other than the root, must have at least two children. This helps in the compression of the trie into a tree structure.
|
345 | 345 | - Leaf Labels: The leaves are often labeled with the start indices of the suffixes in the original string. This allows for efficient pattern matching and other operations.
|
346 | 346 | - Single String Representation: A Suffix Tree is typically built for a single input string. If used for multiple strings, a unique termination symbol must be appended to each string to ensure that no string is a prefix of another.
|
| 347 | + |
| 348 | +##### Fenwick Tree ~ Binary Indexed Tree ~ BIT |
| 349 | + |
| 350 | +The *Fenwick Tree*, also known as *Binary Indexed Tree (BIT)*, is a data structure that provides efficient methods for performing prefix sums (cumulative sums) on an array of numbers. |
| 351 | + |
| 352 | +It's especially beneficial for arrays that are frequently updated. The Fenwick Tree strikes a balance between the raw speed of array-based structures and the dynamic properties of tree-based structures. Its logarithmic operation time makes it a valuable tool for specific problems where both updates to the data and cumulative queries are frequent. |
| 353 | + |
| 354 | +##### Fenwick Tree : Time Complexity |
| 355 | + |
| 356 | +- *Query (Prefix Sum)*: `O(log n)` |
| 357 | +- *Update*: `O(log n)` |
| 358 | + |
| 359 | +##### Fenwick Tree : Application |
| 360 | + |
| 361 | +- *Dynamic Cumulative Sums*: If you need to maintain a dynamic list of numbers where you frequently update the numbers and query the cumulative sum, a Fenwick Tree offers a balance between update and query efficiency. |
| 362 | +- *Range Sum Queries*: With slight modifications, it can be used for range sum queries, where you want to find out the sum of numbers between any two indices quickly. |
| 363 | +- *Inversion Count in an Array*: Fenwick Tree can be employed to count the number of inversions in an array more efficiently than using a simple nested loop approach. |
| 364 | +- *Implementing Advanced Data Structures*: It can be used to implement more advanced data structures like order-statistic trees. |
0 commit comments