Write an Algorithm for Balanced Parentheses for the followin
Solution
Step 1: Store the Expression in a character array
Step 2: Create an Enumeration for each parenthesis (open and close).
Step 3: Create an array OPEN whose size is equal to number of open parenthesis taken in the enumeration.
Step 4: Create an array CLOSE whose size is equal to number of close parenthesis taken in the enumeration.
Step 5: Repeat Step 6 and Step 7 till Expression character is empty
Step 6: Extract a character from the Expression array
Step 7: If the extracted character is an open parenthesis
Then Increment the OPEN index position (index position: is the enumeration number for the open parenthesis) by one.
If the extracted character is a close parenthesis
Then Increment the CLOSE index position (index position: is the enumeration number for the close parenthesis) by one.
Step 8: Compare the each index position of OPEN and CLOSE (Non Zero value index position)
If it is not equal then mismatch of parenthesis
If it is equal then parenthesis are matching.
![Write an Algorithm for Balanced Parentheses for the following code. Don\'t use a stack, and show what are the the results? {int x = 5; double [] csci235; doubl Write an Algorithm for Balanced Parentheses for the following code. Don\'t use a stack, and show what are the the results? {int x = 5; double [] csci235; doubl](/WebImages/35/write-an-algorithm-for-balanced-parentheses-for-the-followin-1105945-1761585338-0.webp)