O'Reilly logo

Learning Functional Data Structures and Algorithms by Raju Kumar Mishra, Atul Khot

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Modifying a list value

What happens when we try to modify a list value? As before, copying and sharing kicks in to make the data structure persistent.

Modifying a list value

We changed the fourth node's value from 17 to 97. To keep the persistent view correct, for V1, we had to copy all the nodes on the path leading up to the modified node.

On the other hand, nodes on all other paths are shared. The case with node deletion is also the same.

Modifying a list value

Note that the copying process is the same as the earlier node modification case.

The insertion case would be similar as well. Play ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required