Closed harshey1103 closed 1 year ago
Just as an additional thing, your depth'
function isn't tail-recursive. I'm totally fine with this but it might be a nice exercise to see if you can make it tail-recursive. Some extra info on that: https://www.cs.cornell.edu/courses/cs3110/2014fa/recitations/5/rec05.html
Hi @patricoferris, I looked into the test directory but I am not able to figure out how to write a test for the depth function. There aren't any tests for the Rtree module. :'(
Yes the tests are a little disorganised, apologies! There are tests of the Rtree module though. For example
Here we test the OMT loader for an instantiation of the Rtree module using rectangles and lines. This should help write a test to check the depth
function :))
I tried to make the function tail recursive and have written the tests can you please have a look @patricoferris @AryanGodara .
The changes are looking good to me. Our CI system seems a bit broken, so I've opened an issue for them: https://github.com/ocurrent/solver-service/issues/74. I ran this locally and I'm happing with the changes, thank you @harshey1103 :))
One thing I would add is that the depth function is not quite tail-recursive here (the function call is not in the tail position) but that's okay, I think something else might break before we get depths that cause us trouble... I think
Initial implementation of depth function. The function returns 0 for an empty tree and 1 for a tree whose root is a leaf.