Question: 4. Please revise the parenthesis matching algorithm pseudo code that we discussed in class so that it a will work with multiple types of parenthesis
4. Please revise the parenthesis matching algorithm pseudo code that we discussed in class so that it a will work with multiple types of parenthesis (e.g.parentheses, square brackets, curly brackets) b. indicates the location of the first offense if the string does not have the matching parenthesis. Your algorithm must be general enough that works with any string you may receive from the user Some sample input you may expect, and the corresponding results: a(b(cd)) -- OK a(bed) -- Location I doesn't have a matching) afbe) -- location 2 doesn't have a matching a([bc]) -- OK . ([bc])) -- location 8 doesn't have a matching! Note: You are writing ONE algorithm that works for both a and b above. 5. Please write an algorithm in pseudo code so that it moves all the contents in a stack into a queue. Your final queue must have the items in the same order as they were in the stack. For example, if from the bottom to the top of the stack is "A, B, Ch. Your queue should have it from the front to rear as "A, B, and C". As usual, your algorithm must be general enough so that it works for any size of the stack and queues. Original Stack Final Queue B A B A
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
