Explanation
- A **Finger Tree** is a data structure that supports efficient access and updates at both ends of a sequence (like a deque) and allows efficient range queries and updates.
-
- It’s often used for sequences where you need to access both ends and perform frequent insertions and deletions.
-
-
Steps:
- The finger tree has a finger (a pointer) to a specific position in the sequence, which enables efficient access to both ends and arbitrary positions.
- Insertion/Deletion: The structure supports logarithmic-time operations to add/remove elements from both ends.
-
Time Complexity:
- Access/Insertion/Deletion: O(log n)
- Query: O(log n) for general operations, O(1) for accessing ends.