4 ms·
This just illustrates the power of recursion. With it, the call stack becomes your invisible data structure - it keeps all saved program state deep down. The sa
by bluetomcat 4y ago
This just illustrates the power of recursion. With it, the call stack becomes your invisible data structure - it keeps all saved program state deep down. The same approach is used to write recursive-descent parsers for languages with an inherently recursive definition.
You could also devise an iterative solution that wouldn't be more complex - then you simply have to maintain explicit stacks for operators and operands.