Herman Code πŸš€

Ukkonens suffix tree algorithm in plain English

February 20, 2025

Ukkonens suffix tree algorithm in plain English

Ideate looking for a circumstantial construction inside a monolithic matter papers. Conventional hunt strategies tin beryllium dilatory and inefficient. Present, ideate a information construction that permits you to pinpoint immoderate substring about immediately. That’s the powerfulness of Ukkonen’s suffix actor algorithm. This ingenious algorithm constructs a suffix actor, a almighty information construction for businesslike drawstring operations, successful linear clip. This article volition delve into the workings of Ukkonen’s algorithm, explaining its center ideas successful plain Nation and demonstrating its applicable functions.

Knowing Suffix Bushes

Earlier diving into Ukkonen’s algorithm, fto’s make clear what a suffix actor is. A suffix actor for a drawstring represents each suffixes of that drawstring successful a actor-similar construction. All way from the base to a leafage node represents a suffix, and all border is labeled with a substring of the first drawstring. This construction permits for extremely accelerated searches for patterns inside the drawstring.

For illustration, see the drawstring “banana$”. (The “$” is a particular quality marking the extremity of the drawstring.) Its suffixes are “banana$”, “anana$”, “nana$”, “ana$”, “na$”, “a$”, and “$”. A suffix actor for this drawstring would incorporate paths representing all of these suffixes.

The appearance of a suffix actor lies successful its quality to find immoderate substring of the first drawstring successful clip proportional to the dimension of the substring being searched, careless of the dimension of the first matter. This makes it importantly quicker than conventional drawstring looking algorithms.

Ukkonen’s Algorithm: A Measure-by-Measure Attack

Ukkonen’s algorithm constructs a suffix actor on-line, which means it builds the actor 1 quality astatine a clip. This is a cardinal vantage complete another suffix actor operation algorithms. It plant by iteratively including all quality of the enter drawstring to the actor, sustaining the accurate suffix actor construction astatine all measure.

The algorithm makes use of respective cardinal ideas: progressive nodes, implicit suffixes, and suffix hyperlinks. These ideas, piece sounding analyzable, are the gathering blocks that let the algorithm to effectively replace the actor. They facilitate speedy navigation and manipulation of the actor construction arsenic fresh characters are added.

The center of the algorithm revolves about effectively managing these implicit suffixes and extending them arsenic fresh characters are added. This includes traversing the actor, creating fresh nodes and edges, and updating suffix hyperlinks to keep the accurate construction. Piece the particulars tin beryllium intricate, the general procedure is remarkably elegant.

Cardinal Ideas and Optimizations

Knowing the function of progressive nodes, implicit suffixes, and suffix hyperlinks is important for greedy the ratio of Ukkonen’s algorithm. The progressive node represents the component successful the actor wherever the algorithm is presently running. Implicit suffixes are suffixes that are implicitly represented successful the actor however don’t person specific leafage nodes. Suffix hyperlinks link nodes representing suffixes that disagree by a azygous quality astatine the opening. These hyperlinks are important for accelerated navigation inside the actor.

Ukkonen’s algorithm employs respective optimizations to accomplish linear clip complexity. 1 cardinal optimization is the usage of suffix hyperlinks, which let the algorithm to rapidly leap betwixt associated elements of the actor. Different crucial optimization is the “skip/number device,” which permits the algorithm to effectively procedure agelong runs of the aforesaid quality.

These optimizations brand Ukkonen’s algorithm a almighty implement for establishing suffix timber successful linear clip, making it applicable for usage with equal precise ample strings.

Applicable Functions and Examples

Suffix bushes, constructed effectively utilizing Ukkonen’s algorithm, person divers purposes crossed assorted fields. Successful bioinformatics, they are important for duties similar genome sequencing and figuring out communal substrings successful Polymer. Successful matter editors, they powerfulness options specified arsenic “discovery each occurrences” and autocomplete. They besides drama a important function successful information compression and plagiarism detection.

See looking out for the form “ana” successful the drawstring “banana”. Utilizing a suffix actor, we tin find each occurrences of “ana” successful a fewer steps by traversing the actor, pursuing the edges labeled ‘a’, ’n’, and ‘a’. This is overmuch sooner than conventional drawstring looking out algorithms, particularly for ample texts. Ideate looking out inside a multi-gigabyte genome database – the ratio turns into paramount.

Different illustration is successful plagiarism detection, wherever suffix timber tin rapidly place equivalent oregon akin passages betwixt paperwork. By representing the paperwork arsenic suffix bushes, comparisons go drastically quicker, enabling businesslike recognition of possible plagiarism.

  • Linear clip operation: Builds the suffix actor quality by quality.
  • Businesslike drawstring operations: Permits accelerated substring searches and another drawstring operations.
  1. Initialize an bare suffix actor.
  2. Iteratively adhd all quality of the enter drawstring.
  3. Replace the actor construction utilizing progressive nodes, implicit suffixes, and suffix hyperlinks.

“Ukkonen’s algorithm is a marvel of algorithm plan. Its elegant usage of progressive nodes and suffix hyperlinks permits linear clip suffix actor operation, a feat not easy achieved.” - Machine Discipline Prof, [Quotation Wanted]

Featured Snippet: Ukkonen’s algorithm is a linear-clip algorithm for setting up suffix bushes, a almighty information construction utilized for businesslike drawstring operations. It achieves its ratio done intelligent usage of progressive nodes, implicit suffixes, and suffix hyperlinks.

Larn Much Astir Suffix Timber- Accelerated form matching

  • Longest communal substring recognition

Often Requested Questions

Q: What is the clip complexity of Ukkonen’s algorithm?

A: Ukkonen’s algorithm has a linear clip complexity, O(n), wherever n is the dimension of the enter drawstring.

Ukkonen’s suffix actor algorithm is a almighty implement for anybody running with matter information. Its linear-clip operation and businesslike drawstring matching capabilities unfastened ahead a planet of potentialities. From genomic sequencing to plagiarism detection, Ukkonen’s algorithm has revolutionized however we procedure and analyse matter. Research additional assets and delve deeper into the intricacies of this fascinating algorithm to unlock its afloat possible. Dive deeper into the planet of algorithms and information buildings with sources connected suffix arrays, generalized suffix bushes, and another precocious drawstring algorithms. Studying astir these precocious ideas volition additional heighten your knowing of businesslike matter processing and unfastened ahead fresh avenues for exploration.

Wikipedia: Ukkonen’s Algorithm

Esko Ukkonen’s Webpage

GeeksforGeeks: Ukkonen’s Suffix Actor Operation

Question & Answer :
I awareness a spot deep astatine this component. I’ve spent days making an attempt to full wrapper my caput about suffix actor operation, however due to the fact that I don’t person a mathematical inheritance, galore of the explanations elude maine arsenic they commencement to brand extreme usage of mathematical symbology. The closest to a bully mentation that I’ve recovered is Accelerated Drawstring Looking With Suffix Bushes, however helium glosses complete assorted factors and any facets of the algorithm stay unclear.

A measure-by-measure mentation of this algorithm present connected Stack Overflow would beryllium invaluable for galore others too maine, I’m certain.

For mention, present’s Ukkonen’s insubstantial connected the algorithm: http://www.cs.helsinki.fi/u/ukkonen/SuffixT1withFigs.pdf

My basal knowing, truthful cold:

  • I demand to iterate done all prefix P of a fixed drawstring T
  • I demand to iterate done all suffix S successful prefix P and adhd that to actor
  • To adhd suffix S to the actor, I demand to iterate done all quality successful S, with the iterations consisting of both strolling behind an current subdivision that begins with the aforesaid fit of characters C successful S and possibly splitting an border into descendent nodes once I range a differing quality successful the suffix, Oregon if location was nary matching border to locomotion behind. Once nary matching border is recovered to locomotion behind for C, a fresh leafage border is created for C.

The basal algorithm seems to beryllium O(n2), arsenic is pointed retired successful about explanations, arsenic we demand to measure done each of the prefixes, past we demand to measure done all of the suffixes for all prefix. Ukkonen’s algorithm is seemingly alone due to the fact that of the suffix pointer method helium makes use of, although I deliberation that is what I’m having problem knowing.

I’m besides having problem knowing:

  • precisely once and however the “progressive component” is assigned, utilized and modified
  • what is going connected with the canonization facet of the algorithm
  • Wherefore the implementations I’ve seen demand to “hole” bounding variables that they are utilizing

Present is the accomplished C# origin codification. It not lone plant appropriately, however helps computerized canonization and renders a nicer wanting matter graph of the output. Origin codification and example output is astatine:

https://gist.github.com/2373868


Replace 2017-eleven-04

Last galore years I’ve recovered a fresh usage for suffix timber, and person applied the algorithm successful JavaScript. Gist is beneath. It ought to beryllium bug-escaped. Dump it into a js record, npm instal chalk from the aforesaid determination, and past tally with node.js to seat any vibrant output. Location’s a stripped behind interpretation successful the aforesaid Gist, with out immoderate of the debugging codification.

https://gist.github.com/axefrog/c347bf0f5e0723cbd09b1aaed6ec6fc6

The pursuing is an effort to depict the Ukkonen algorithm by archetypal displaying what it does once the drawstring is elemental (i.e. does not incorporate immoderate repeated characters), and past extending it to the afloat algorithm.

Archetypal, a fewer preliminary statements.

  1. What we are gathering, is fundamentally similar a hunt trie. Truthful location is a base node, edges going retired of it starring to fresh nodes, and additional edges going retired of these, and truthful away
  2. However: Dissimilar successful a hunt trie, the border labels are not azygous characters. Alternatively, all border is labeled utilizing a brace of integers [from,to]. These are pointers into the matter. Successful this awareness, all border carries a drawstring description of arbitrary dimension, however takes lone O(1) abstraction (2 pointers).

Basal rule

I would similar to archetypal show however to make the suffix actor of a peculiarly elemental drawstring, a drawstring with nary repeated characters:

abc 

The algorithm plant successful steps, from near to correct. Location is 1 measure for all quality of the drawstring. All measure mightiness affect much than 1 idiosyncratic cognition, however we volition seat (seat the last observations astatine the extremity) that the entire figure of operations is O(n).

Truthful, we commencement from the near, and archetypal insert lone the azygous quality a by creating an border from the base node (connected the near) to a leafage, and labeling it arsenic [zero,#], which means the border represents the substring beginning astatine assumption zero and ending astatine the actual extremity. I usage the signal # to average the actual extremity, which is astatine assumption 1 (correct last a).

Truthful we person an first actor, which appears similar this:

And what it means is this:

Present we advancement to assumption 2 (correct last b). Our end astatine all measure is to insert each suffixes ahead to the actual assumption. We bash this by

  • increasing the current a-border to ab
  • inserting 1 fresh border for b

Successful our cooperation this appears similar

enter image description here

And what it means is:

We detect 2 issues:

  • The border cooperation for ab is the aforesaid arsenic it utilized to beryllium successful the first actor: [zero,#]. Its which means has routinely modified due to the fact that we up to date the actual assumption # from 1 to 2.
  • All border consumes O(1) abstraction, due to the fact that it consists of lone 2 pointers into the matter, careless of however galore characters it represents.

Adjacent we increment the assumption once more and replace the actor by appending a c to all current border and inserting 1 fresh border for the fresh suffix c.

Successful our cooperation this appears similar

And what it means is:

We detect:

  • The actor is the accurate suffix actor ahead to the actual assumption last all measure
  • Location are arsenic galore steps arsenic location are characters successful the matter
  • The magnitude of activity successful all measure is O(1), due to the fact that each current edges are up to date robotically by incrementing #, and inserting the 1 fresh border for the last quality tin beryllium completed successful O(1) clip. Therefore for a drawstring of dimension n, lone O(n) clip is required.

Archetypal delay: Elemental repetitions

Of class this plant truthful properly lone due to the fact that our drawstring does not incorporate immoderate repetitions. We present expression astatine a much real looking drawstring:

abcabxabcd 

It begins with abc arsenic successful the former illustration, past ab is repeated and adopted by x, and past abc is repeated adopted by d.

Steps 1 done three: Last the archetypal three steps we person the actor from the former illustration:

Measure four: We decision # to assumption four. This implicitly updates each current edges to this:

and we demand to insert the last suffix of the actual measure, a, astatine the base.

Earlier we bash this, we present 2 much variables (successful summation to #), which of class person been location each the clip however we haven’t utilized them truthful cold:

  • The progressive component, which is a triple (active_node,active_edge,active_length)
  • The the rest, which is an integer indicating however galore fresh suffixes we demand to insert

The direct which means of these 2 volition go broad shortly, however for present fto’s conscionable opportunity:

  • Successful the elemental abc illustration, the progressive component was ever (base,'\0x',zero), i.e. active_node was the base node, active_edge was specified arsenic the null quality '\0x', and active_length was zero. The consequence of this was that the 1 fresh border that we inserted successful all measure was inserted astatine the base node arsenic a freshly created border. We volition seat shortly wherefore a triple is essential to correspond this accusation.
  • The the rest was ever fit to 1 astatine the opening of all measure. The which means of this was that the figure of suffixes we had to actively insert astatine the extremity of all measure was 1 (ever conscionable the last quality).

Present this is going to alteration. Once we insert the actual last quality a astatine the base, we announcement that location is already an outgoing border beginning with a, particularly: abca. Present is what we bash successful specified a lawsuit:

  • We bash not insert a caller border [four,#] astatine the base node. Alternatively we merely announcement that the suffix a is already successful our actor. It ends successful the mediate of a longer border, however we are not bothered by that. We conscionable permission issues the manner they are.
  • We fit the progressive component to (base,'a',1). That means the progressive component is present location successful the mediate of outgoing border of the base node that begins with a, particularly, last assumption 1 connected that border. We announcement that the border is specified merely by its archetypal quality a. That suffices due to the fact that location tin beryllium lone 1 border beginning with immoderate peculiar quality (corroborate that this is actual last speechmaking done the full statement).
  • We besides increment the rest, truthful astatine the opening of the adjacent measure it volition beryllium 2.

Reflection: Once the last suffix we demand to insert is recovered to be successful the actor already, the actor itself is not modified astatine each (we lone replace the progressive component and the rest). The actor is past not an close cooperation of the suffix actor ahead to the actual assumption immoderate much, however it comprises each suffixes (due to the fact that the last suffix a is contained implicitly). Therefore, isolated from updating the variables (which are each of mounted dimension, truthful this is O(1)), location was nary activity executed successful this measure.

Measure 5: We replace the actual assumption # to 5. This mechanically updates the actor to this:

And due to the fact that the rest is 2, we demand to insert 2 last suffixes of the actual assumption: ab and b. This is fundamentally due to the fact that:

  • The a suffix from the former measure has ne\’er been decently inserted. Truthful it has remained, and since we person progressed 1 measure, it has present grown from a to ab.
  • And we demand to insert the fresh last border b.

Successful pattern this means that we spell to the progressive component (which factors to down the a connected what is present the abcab border), and insert the actual last quality b. However: Once more, it turns retired that b is besides already immediate connected that aforesaid border.

Truthful, once more, we bash not alteration the actor. We merely:

  • Replace the progressive component to (base,'a',2) (aforesaid node and border arsenic earlier, however present we component to down the b)
  • Increment the the rest to three due to the fact that we inactive person not decently inserted the last border from the former measure, and we don’t insert the actual last border both.

To beryllium broad: We had to insert ab and b successful the actual measure, however due to the fact that ab was already recovered, we up to date the progressive component and did not equal effort to insert b. Wherefore? Due to the fact that if ab is successful the actor, all suffix of it (together with b) essential beryllium successful the actor, excessively. Possibly lone implicitly, however it essential beryllium location, due to the fact that of the manner we person constructed the actor truthful cold.

We continue to measure 6 by incrementing #. The actor is robotically up to date to:

Due to the fact that the rest is three, we person to insert abx, bx and x. The progressive component tells america wherever ab ends, truthful we lone demand to leap location and insert the x. So, x is not location but, truthful we divided the abcabx border and insert an inner node:

The border representations are inactive pointers into the matter, truthful splitting and inserting an inner node tin beryllium executed successful O(1) clip.

Truthful we person dealt with abx and decrement the rest to 2. Present we demand to insert the adjacent remaining suffix, bx. However earlier we bash that we demand to replace the progressive component. The regulation for this, last splitting and inserting an border, volition beryllium referred to as Regulation 1 beneath, and it applies every time the active_node is base (we volition larn regulation three for another circumstances additional beneath). Present is regulation 1:

Last an insertion from base,

  • active_node stays base
  • active_edge is fit to the archetypal quality of the fresh suffix we demand to insert, i.e. b
  • active_length is diminished by 1

Therefore, the fresh progressive-component triple (base,'b',1) signifies that the adjacent insert has to beryllium made astatine the bcabx border, down 1 quality, i.e. down b. We tin place the insertion component successful O(1) clip and cheque whether or not x is already immediate oregon not. If it was immediate, we would extremity the actual measure and permission all the things the manner it is. However x is not immediate, truthful we insert it by splitting the border:

Once more, this took O(1) clip and we replace the rest to 1 and the progressive component to (base,'x',zero) arsenic regulation 1 states.

However location is 1 much happening we demand to bash. We’ll call this Regulation 2:

If we divided an border and insert a fresh node, and if that is not the archetypal node created throughout the actual measure, we link the antecedently inserted node and the fresh node done a particular pointer, a suffix nexus. We volition future seat wherefore that is utile. Present is what we acquire, the suffix nexus is represented arsenic a dotted border:

We inactive demand to insert the last suffix of the actual measure, x. Since the active_length constituent of the progressive node has fallen to zero, the last insert is made astatine the base straight. Since location is nary outgoing border astatine the base node beginning with x, we insert a fresh border:

Arsenic we tin seat, successful the actual measure each remaining inserts have been made.

We continue to measure 7 by mounting #=7, which robotically appends the adjacent quality, a, to each leafage edges, arsenic ever. Past we effort to insert the fresh last quality to the progressive component (the base), and discovery that it is location already. Truthful we extremity the actual measure with out inserting thing and replace the progressive component to (base,'a',1).

Successful measure eight, #=eight, we append b, and arsenic seen earlier, this lone means we replace the progressive component to (base,'a',2) and increment the rest with out doing thing other, due to the fact that b is already immediate. Nevertheless, we announcement (successful O(1) clip) that the progressive component is present astatine the extremity of an border. We indicate this by re-mounting it to (node1,'\0x',zero). Present, I usage node1 to mention to the inner node the ab border ends astatine.

Past, successful measure #=9, we demand to insert ‘c’ and this volition aid america to realize the last device:

Arsenic ever, the # replace appends c mechanically to the leafage edges and we spell to the progressive component to seat if we tin insert ‘c’. It turns retired ‘c’ exists already astatine that border, truthful we fit the progressive component to (node1,'c',1), increment the rest and bash thing other.

Present successful measure #=10, the rest is four, and truthful we archetypal demand to insert abcd (which stays from three steps agone) by inserting d astatine the progressive component.

Making an attempt to insert d astatine the progressive component causes an border divided successful O(1) clip:

The active_node, from which the divided was initiated, is marked successful reddish supra. Present is the last regulation, Regulation three:

Last splitting an border from an active_node that is not the base node, we travel the suffix nexus going retired of that node, if location is immoderate, and reset the active_node to the node it factors to. If location is nary suffix nexus, we fit the active_node to the base. active_edge and active_length stay unchanged.

Truthful the progressive component is present (node2,'c',1), and node2 is marked successful reddish beneath:

Since the insertion of abcd is absolute, we decrement the rest to three and see the adjacent remaining suffix of the actual measure, bcd. Regulation three has fit the progressive component to conscionable the correct node and border truthful inserting bcd tin beryllium performed by merely inserting its last quality d astatine the progressive component.

Doing this causes different border divided, and due to the fact that of regulation 2, we essential make a suffix nexus from the antecedently inserted node to the fresh 1:

We detect: Suffix hyperlinks change america to reset the progressive component truthful we tin brand the adjacent remaining insert astatine O(1) attempt. Expression astatine the graph supra to corroborate that so node astatine description ab is linked to the node astatine b (its suffix), and the node astatine abc is linked to bc.

The actual measure is not completed but. the rest is present 2, and we demand to travel regulation three to reset the progressive component once more. Since the actual active_node (reddish supra) has nary suffix nexus, we reset to base. The progressive component is present (base,'c',1).

Therefore the adjacent insert happens astatine the 1 outgoing border of the base node whose description begins with c: cabxabcd, down the archetypal quality, i.e. down c. This causes different divided:

And since this includes the instauration of a fresh inner node,we travel regulation 2 and fit a fresh suffix nexus from the antecedently created inner node:

(I americium utilizing Graphviz Dot for these small graphs. The fresh suffix nexus prompted dot to re-put the current edges, truthful cheque cautiously to corroborate that the lone happening that was inserted supra is a fresh suffix nexus.)

With this, the rest tin beryllium fit to 1 and since the active_node is base, we usage regulation 1 to replace the progressive component to (base,'d',zero). This means the last insert of the actual measure is to insert a azygous d astatine base:

That was the last measure and we are completed. Location are figure of last observations, although:

  • Successful all measure we decision # guardant by 1 assumption. This mechanically updates each leafage nodes successful O(1) clip.
  • However it does not woody with a) immoderate suffixes remaining from former steps, and b) with the 1 last quality of the actual measure.
  • the rest tells america however galore further inserts we demand to brand. These inserts correspond 1-to-1 to the last suffixes of the drawstring that ends astatine the actual assumption #. We see 1 last the another and brand the insert. Crucial: All insert is accomplished successful O(1) clip since the progressive component tells america precisely wherever to spell, and we demand to adhd lone 1 azygous quality astatine the progressive component. Wherefore? Due to the fact that the another characters are contained implicitly (other the progressive component would not beryllium wherever it is).
  • Last all specified insert, we decrement the rest and travel the suffix nexus if location is immoderate. If not we spell to base (regulation three). If we are astatine base already, we modify the progressive component utilizing regulation 1. Successful immoderate lawsuit, it takes lone O(1) clip.
  • If, throughout 1 of these inserts, we discovery that the quality we privation to insert is already location, we don’t bash thing and extremity the actual measure, equal if the rest>zero. The ground is that immoderate inserts that stay volition beryllium suffixes of the 1 we conscionable tried to brand. Therefore they are each implicit successful the actual actor. The information that the rest>zero makes certain we woody with the remaining suffixes future.
  • What if astatine the extremity of the algorithm the rest>zero? This volition beryllium the lawsuit every time the extremity of the matter is a substring that occurred location earlier. Successful that lawsuit we essential append 1 other quality astatine the extremity of the drawstring that has not occurred earlier. Successful the lit, normally the dollar gesture $ is utilized arsenic a signal for that. Wherefore does that substance? –> If future we usage the accomplished suffix actor to hunt for suffixes, we essential judge matches lone if they extremity astatine a leafage. Other we would acquire a batch of spurious matches, due to the fact that location are galore strings implicitly contained successful the actor that are not existent suffixes of the chief drawstring. Forcing the rest to beryllium zero astatine the extremity is basically a manner to guarantee that each suffixes extremity astatine a leafage node. Nevertheless, if we privation to usage the actor to hunt for broad substrings, not lone suffixes of the chief drawstring, this last measure is so not required, arsenic recommended by the OP’s remark beneath.
  • Truthful what is the complexity of the full algorithm? If the matter is n characters successful dimension, location are evidently n steps (oregon n+1 if we adhd the dollar gesture). Successful all measure we both bash thing (another than updating the variables), oregon we brand the rest inserts, all taking O(1) clip. Since the rest signifies however galore occasions we person completed thing successful former steps, and is decremented for all insert that we brand present, the entire figure of occasions we bash thing is precisely n (oregon n+1). Therefore, the entire complexity is O(n).
  • Nevertheless, location is 1 tiny happening that I did not decently explicate: It tin hap that we travel a suffix nexus, replace the progressive component, and past discovery that its active_length constituent does not activity fine with the fresh active_node. For illustration, see a occupation similar this:

(The dashed strains bespeak the remainder of the actor. The dotted formation is a suffix nexus.)

Present fto the progressive component beryllium (reddish,'d',three), truthful it factors to the spot down the f connected the defg border. Present presume we made the essential updates and present travel the suffix nexus to replace the progressive component in accordance to regulation three. The fresh progressive component is (greenish,'d',three). Nevertheless, the d-border going retired of the greenish node is de, truthful it has lone 2 characters. Successful command to discovery the accurate progressive component, we evidently demand to travel that border to the bluish node and reset to (bluish,'f',1).

Successful a peculiarly atrocious lawsuit, the active_length may beryllium arsenic ample arsenic the rest, which tin beryllium arsenic ample arsenic n. And it mightiness precise fine hap that to discovery the accurate progressive component, we demand not lone leap complete 1 inner node, however possibly galore, ahead to n successful the worst lawsuit. Does that average the algorithm has a hidden O(n2) complexity, due to the fact that successful all measure the rest is mostly O(n), and the station-changes to the progressive node last pursuing a suffix nexus may beryllium O(n), excessively?

Nary. The ground is that if so we person to set the progressive component (e.g. from greenish to bluish arsenic supra), that brings america to a fresh node that has its ain suffix nexus, and active_length volition beryllium decreased. Arsenic we travel behind the concatenation of suffix hyperlinks we brand the remaining inserts, active_length tin lone change, and the figure of progressive-component changes we tin brand connected the manner tin’t beryllium bigger than active_length astatine immoderate fixed clip. Since active_length tin ne\’er beryllium bigger than the rest, and the rest is O(n) not lone successful all azygous measure, however the entire sum of increments always made to the rest complete the class of the full procedure is O(n) excessively, the figure of progressive component changes is besides bounded by O(n).