Unveiling the Power of Visualization in Problem-Solving

Problems can be reformulated in different ways. Often, just translating something into pictorial form does wonders. The visual models of the problem can be decision trees, tables, charts, number lines, grids, state diagrams or any diagrams that capture the essence of the problem. The models we build at this stage may map directly to computational models. For instance decision trees usually map directly to recursion trees.

Some models may require slight variations to map to its computational equivalent model. For instance, the conceptual model of the Trapping Rain Water problem is a bar chart and the computational model overlays left scan and right scan to find the intersecting area that represents the trapped water.

From Conceptual to Computational Models

Visualization is a crucial tool in the process of problem-solving, and it extends well beyond simple charts or sketches. Visualization is the act of converting abstract concepts or complex data into a form that can be more readily processed and understood by the human mind. A well-executed visualization can reveal patterns, relationships, and structures that might otherwise remain hidden.

A problem can often be looked at from several perspectives, each offering its unique insights. For instance, a given problem may be reformulated visually in several ways such as decision trees, tables, charts, number lines, grids, or state diagrams. These visual representations serve to encapsulate the crux of the problem, making it easier to grasp its intricacies.

Take, for instance, the decision trees. These are particularly useful for problems involving choices or probabilities. They can map directly to recursion trees, which are frequently used in computational problem solving. A decision tree breaks down a decision or a series of decisions into its various possible outcomes, thereby laying bare the structure of the problem. The branches of a decision tree represent potential choices and the associated outcomes, making it easier to follow the various paths to their conclusion.

However, the process of transforming a conceptual model into its computational equivalent isn’t always straightforward. Some conceptual models may require modifications or tweaks to map accurately to their computational counterparts.

Consider the problem of Trapping Rain Water, where the aim is to find the maximum amount of water that can be trapped between bars of different heights. The conceptual model for this problem could be a bar chart, which visualizes the heights of the bars and the spaces between them where water could potentially be trapped. The computational model, on the other hand, involves two scans - a left scan and a right scan - which locate the highest bars on either side of a given bar. The intersecting area between the two scans represents the trapped water.

This example shows how visual models not only aid in understanding the problem but also pave the way for devising computational strategies to solve it. They act as a bridge between the abstract problem and the concrete algorithmic solution. By enabling us to see the problem in a new light, visual models serve to expand our problem-solving toolkit, enhancing our ability to tackle complex problems.

Trapping Rain Water

This problem can be visualized as an array of bars of different heights. The idea is to calculate the total amount of water that can be trapped in the spaces between the bars.

The key insight to solving this problem is to realize that the amount of water that can be trapped at a given bar is determined by the highest bar to the left and the highest bar to the right. Specifically, the water trapped at the current bar is the minimum of the heights of the highest bars on either side, minus the height of the current bar.

You can create a visualization that shows the array of bars, as well as two lines that show the highest bars to the left and right of each position. This will help you understand how the algorithm works.

To translate this to a computational model, you would create two arrays, leftMax and rightMax, that keep track of the highest bar to the left and right of each position, respectively. Then, you would iterate through the original array, calculating the water at each bar as described above and adding it to a total.

This is an example of how visualization can help understand and solve a complex problem, and how that visual model can be translated into a computational model.