0

Well of course you can go through all the nodes and you will get it in O(n). I just want to know if it's possible to do it faster.

  • 1
    No, unless you have some other information in advance, because if you don't look at all the nodes, then the one you didn't look at might be the maximum. Of course, if they're in a tree, and you know something about how the tree was set up, it could easily be O(1) because you do have more info. – Kenny Ostrom Mar 26 '22 at 15:52
  • If the tree has no specific properties, then it gives no benefit over an array. – trincot Mar 26 '22 at 17:52

0 Answers0