walkccc / CLRS

📚 Solutions to Introduction to Algorithms Third Edition
https://walkccc.me/CLRS
MIT License
4.63k stars 1.26k forks source link

10.2-4 need to consider x equals to L.nil #461

Open funny1dog opened 1 year ago

funny1dog commented 1 year ago

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.