3 ms·
in a lot of other languages you would be passing things by reference; the concept of an address would not be needed to implement a linked list.
by zem 6y ago
in a lot of other languages you would be passing things by reference; the concept of an address would not be needed to implement a linked list.
- nybble41 6y agoSure, in those other languages you could just define a single-field class to wrap the reference to the next node, since you can only pass objects by reference and references themselves are (usually) not objects. Unfortunately this adds a lot of overhead, both in lines of code and runtime. Instead you would probably just use the less efficient algorithm with more special cases to work around the lack of indirect references.