Algorithm – parenthesis matching using stacks

In computer science, stack data structure serves a variety of uses, from operating system function pointer management to compiler construction. We will try to be less ambitious and use the stack to solve the parenthesis matching problem. Instead of using the stack data structure explicitly, we will implicitly use stack operations to show you how to use the stack constructs within the algorithm.

A typical arithmetic expression is usually written as follows:

Algorithm – parenthesis matching using stacks

Here, the parentheses are being used to provide the order in which the operators will be applied in the statement. Also, in various programming languages, ...

Get Learning F# Functional Data Structures and Algorithms now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.