Skip to content

Hare Rope

Rope implementation in harelang.

Tags: programming, math

A Rope is a data structure that manages an ordered set of characters. Just like a string!

You can read more about it on its Wikipedia article.

Some of the key Big-O differences are the following:

OperationRopeString
IndexO(log n)O(1)
SplitO(log n)O(1)
ConcatenateO(1) amort., O(log n) worstO(n)
Iterate over each characterO(n)O(n)
InsertO(log n)O(n)
AppendO(1) amort., O(log n) worstO(1) amort., O(n) worst
DeleteO(log n)O(n)
ReportO(j + log n)O(j)
BuildO(n)O(n)

Table taken from Comparison with monolithic arrays