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.
You are more than likely to run out of memory trying to maintain the data structure than the recursive calls. If you use an assumption that a 64 bit machine uses a 64 bit pointer for the function address then you are pushing 16 bytes per call (8 bytes for the function address and 8 bytes for the heap address of the data object). When you use the stack object to store the data object you have the overhead of the stack object and if that stack object is not implemented correctly the possibility of the data object being passed by value and not by refernce. In this case that could be anywhere from 18 to 24 bytes per object (depending on the size of the int for the data).
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Tree: Postorder Traversal
You are viewing a single comment's thread. Return to all comments →
You are more than likely to run out of memory trying to maintain the data structure than the recursive calls. If you use an assumption that a 64 bit machine uses a 64 bit pointer for the function address then you are pushing 16 bytes per call (8 bytes for the function address and 8 bytes for the heap address of the data object). When you use the stack object to store the data object you have the overhead of the stack object and if that stack object is not implemented correctly the possibility of the data object being passed by value and not by refernce. In this case that could be anywhere from 18 to 24 bytes per object (depending on the size of the int for the data).