Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function in MIPS assembly language that determines whether parentheses in a character string are valid. The following six characters are considered as parentheses:

Write a function in MIPS assembly language that determines whether parentheses in a character string are valid.
The following six characters are considered as parentheses:
(,),[,],{,}
A character string with valid parentheses does the following:
*Every opening parenthesis must be closed with the same type of parenthesis.
*Open parentheses must be closed in the correct order.
*Every closing parenthesis has a corresponding opening parenthesis.
Function specification
The function interface has these inputs and outputs:
Entry: $a0-> the memory address of an ASCIIZ character array.
Output: $v0-> the validation result; 1 if the parentheses are valid, 0 if not.
Write a main program in which you print the string, then call the implemented function, and lastly print valid parentheses or invalid parentheses depending on the return value of the function.
Suggestion. Remember that the stack is a LIFO (Last In, First Out) type structure. Consider how you can take advantage of this property to simplify the validations you must do with each pair of opening and closing parentheses.
An example of what should be seen in the terminal is the following result in the attached imageString:
()[]{}{{{()}[]}()}
Parentesis validos.
-- program is finished running --
String:
Parentesis invalidos.
-- program is finished running --
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Managing Your Information How To Design And Create A Textual Database On Your Microcomputer

Authors: Tenopir, Carol, Lundeen, Gerald

1st Edition

1555700233, 9781555700232

More Books

Students also viewed these Databases questions

Question

What other strategic processes are closely tied to ERM?

Answered: 1 week ago

Question

Describe the concept of decatastrophizing as a treatment procedure.

Answered: 1 week ago