CLRS
CLRS copied to clipboard
10.2-4 need to consider x equals to L.nil
The last line of code: return x which is not considered if x == L.nil, and then it returns L.nil with L.nil.key = k, and how does the return value differentiate it from the normally found elements?
So we need to check if x == L.nil and if it is then set L.nil.key = NIL to solve the issue.