Question: Code in C in this task, we must to build a function int legString(char str[]); to check if our string is legal. function gets string

 Code in C in this task, we must to build a

Code in C in this task, we must to build a function "int legString(char str[]);" to check if our string is legal. function gets string with different types of brackets: (), [], {}, . function must to check if our string is "legal if we opened some brackets, so we must to close them and if between brackets we have "legal string too. for example: legString : string: 123 (123) {12[3]} {123] 123) Create function using by Stack, not by recursion. Algorithm of creating function: *run through the string from left to right *each left bracket will be inserted into the stack *for each right bracket, check the head of a stack : * if there is a suitable left bracket, we will remove it and continue with the test. * if there is no such bracket the string in illegal. *if in the end of running through the string the stack is empty, so string is legal

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!