answersLogoWhite

0


Best Answer

Parse the character stream from the beginning of the sequence to the end, counting characters as you go. Every time you encounter an opening parenthesis, push the current character count onto the stack. Every time you encounter a closing parenthesis, ensure the stack is not empty before popping the top value from the stack. You can discard the value -- you've found a matching pair.

If you attempt to pop from an empty stack, then you have a closing parenthesis at the current character position that has no matching opening parenthesis.

If you reach the end of the test and the stack is not empty, you have at least one opening parenthesis without a matching closing parenthesis. Pop the character positions off the stack to determine where the opening parenthesis are.

User Avatar

Wiki User

9y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: You must write a program in C that uses a stack to check a file for unbalanced parenthesis any suggestions?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

On a 2002 Dakotathe blowermotor is not working any suggestions?

Check the fuse Check the relay Check the switch Check the resistor


1991 Chevy van and the brake lights don't work do you have any suggestions?

Check bulbs Check fuse Check stop light switch check the fuse.


What is the indicator light that is an exclamation in parenthesis on a Subaru Outback?

It is the tire pressure monitoring system.... it's means check your air pressure in your tires!!


Which program would you run to check for possible disk errors and where is the program located?

program would you run to check for possible disk errors


i need a completly free vin check program?

i need a completly free vin check program


How do you choose an affiliate program?

When choosing affiliate program, you need to check the following: 1 - Check the program reputation 2 - Check the company history 3 - Check if they provide dedicated affiliate managers. 4 - Check the tools and promotional content that they provide their affiliates 5 - Try the product and the service that the program offer


What does an unbalanced force create?

An unbalanced force results in an unequal often uncontrolled reaction. If I push you lightly on both sides of your back with equal and balanced force, I might get you to move forward. But if I push really hard on only one side of your back, you would more easily tumble and stumble to the opposite side.


Any suggestions on a good waterproofing company?

There is a lot of good info at Waterproofing.org with tips and suggestions. check out www.aaahomerepair.com


Where can Look housekeeper in Shanghai any suggestions?

i know a excelent company in Shanghai . you check the website www.shhguanjia.com


What are some suggestions that should guide a writer's use of quotations?

Check the Modern Languge Arts Hanbook.


4.7 liter magnum rough idle suggestions?

Check/ replace the TPS if the idle is up and down.


The heat in your 98 expedition will not get hot and you had the thermostat changed already any suggestions?

Check the Blender door... Also check the temp knobs they make be broken.