Persistent data structure: Difference between revisions

Content deleted Content added
Tag: Reverted
Reverting edit(s) by 134.117.247.196 (talk) to rev. 1189764739 by 2A01:4B00:844D:E800:ED23:9DA8:8859:A891: Not providing a reliable source (RW 16.1)
Line 136:
 
Notice two points: first, the original tree (<code>xs</code>) persists. Second, many common nodes are shared between the old tree and the new tree. Such persistence and sharing is difficult to manage without some form of [[Garbage collection (computer science)|garbage collection]] (GC) to automatically free up nodes which have no live references, and this is why GC is a feature commonly found in [[Functional programming|functional programming languages]].
 
'''Time Complexity Analysis: Search, Insertion & Deletion'''
 
In the best scenario (balanced tree), the time complexity would be O(log n) because the height of a balanced binary search tree is O(log n).
In unbalanced trees, the height could potentially grow to O(n), which would result in a worst-case time complexity of O(n).
 
=== Persistent hash array mapped trie ===