Identifying the linear evaluation pattern
The linear evaluation technique we learned earlier can only solve certain types of sequence evaluation problems. These are generally easy or medium problems where we are given a sequence of data items and triggers and certain rules dictating how to evaluate results when we hit a trigger. The sequence must not have any form of nesting, and triggers should always only use data either exclusively before or after them.
If the problem statement or its solution follows the generic template below, it can be solved by using the linear evaluation technique using a stack.
Template:
Given a sequence of data items and triggers without any nesting and a set of evaluation rules on hitting a trigger, evaluate the sequence.
Liking the course? Check our discounted plans to continue learning.