Problems on Stacks.

Problems on Stacks. 




Solve these and post the answers below.



Check for a Palindrome using a Stack

Eg "abcd" is not a palindrome, "aa", "abcba" are palindromes

Check for a proper parenthesis using a Stack

Eg "(1+2*(3+5)" is not properly parenthesized, "(1+2*(3-5)-9)", "()","a+[b-c)" are properly parenthesized.


Find the code inside the parenthesis using a Stack.

Eg "(1+2*(3-5)-9)" will break up into
(3-5) and (1_2*(3-5)-9)

Evaluate the expression inside the parenthesis using a Stack.

Eg "(1+2*(3-5)-9)" will evaluate to -12

Repeat the above problems for expressions with multiple types of brackets.

Eg "[1+2*(3-5)-{9-8}]")



Contact us for software training, education or development










 

Post a Comment

0 Comments

Me