In the case of a tree, you only need to copy the nodes that are actually changing. Let's say you have a tree:
A
/ \
/ \
B C
/ \
D E
If you call your method delete_treewith B as an argument, the only node you need to copy is A, since the CDE subtree is still the same as before the operation.
In addition, if you do not use Tree1 after the operation and only use the resulting tree, the compiler can modify the operation to change the tree directly, which can be faster.
These operations are not very expensive, and for most data structures the excess copy overhead is very small. For some things (i.e. large images loaded as arrays of bytes) you may need creative solutions .
Erlang , . , , 1- , . , , , , , .