T The following is a detailed pseudocode solution to check a


T. The following is a detailed pseudocode solution to check a strin astack create Stacko balanced SoFar a true while balanced ar and i length of astring) ch character at postion in astring Push an open brace Close brace else Ich is isEmptyol Pop matching matching open balance fate ignore all characters astring has balanced braces else astng does not have balanced traces 8. The following figure shows a circular linked list. Show the pict

Solution

Here is the code to be filled for you:

aStack createStack()
balancedSoFar = true
i = 0

while(balancedSoFar and i < length of aString)
{
   ch = character at position i in aString
   ++i
  
   //Push an open brace
   if(ch is \'(\')
       aStack.push(\'(\')
   //Close brace
   else if(ch is \')\')
       if(!aStack isEmpty())   //Pop a matching open string.
           aStack.pop()
       else   //No matching open brace.
           balancedSoFar = false
   //Ignores all characters other than braces              
}
if(balancedSoFar and aStack.isEmpty())
   aString has balanced braces
else
   aString does not have balanced braces.  

 T. The following is a detailed pseudocode solution to check a strin astack create Stacko balanced SoFar a true while balanced ar and i length of astring) ch ch

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site