We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I have solved this problem but I have cheated :-) 'cause I have used a mutable data structure (in Scala).
To solve this problem in a real "functional way" I should have used immutable data structures. This means that every time I had to change something (change value, add, delete) I should have copied/created an entire new tree with only "that" change.
Well, I thought about this for a while but I found this way to approach the problem quite overwhelming. Could anybody show me how to solve this problem with immutable data structures? How do you handle the add/delete/change operations?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Tree manager
You are viewing a single comment's thread. Return to all comments →
I have solved this problem but I have cheated :-) 'cause I have used a mutable data structure (in Scala).
To solve this problem in a real "functional way" I should have used immutable data structures. This means that every time I had to change something (change value, add, delete) I should have copied/created an entire new tree with only "that" change. Well, I thought about this for a while but I found this way to approach the problem quite overwhelming. Could anybody show me how to solve this problem with immutable data structures? How do you handle the add/delete/change operations?