Skip to content

Latest commit

 

History

History
12 lines (7 loc) · 1.28 KB

File metadata and controls

12 lines (7 loc) · 1.28 KB

Evaluating arithmetic expressions - reverse recursive algorithm

New approach to the arithmetic expressions evaluating. Performance comparison with the classical approach (Dijkstra's Shunting-Yard).

This example demonstrate performance gains when evaluationg arithmetic expressions by the algorithm which has been explained in the parsing-arithmetic-expression repository.

So, these performance comparisons have been made here:
(a) Classical approach   vs.   (b) new-algorithm-1   vs.   (c) new-algorithm-2

In other words:
(Shunting-Yard -> RPN -> evaluation)  vs.  (new-algorithm -> RPN -> evaluation)  vs.  (new-algorithm -> in-place evaluation)

It turns out that (b) is faster than (a) and (c) is faster than (b). Moreover, (c) is for a magnitude faster than (a).

Finally, I would like to emphasize - this new approach is good not only because it is faster. I find it scallable as well! It should be very simple to add new operators and rules. I find it fairly simple, with a clear idea behind it. (Note that the evaluation can be done in-place, without a need for intermediary data structures.)