Infix expression has balanced parenthesis or not, Data Structure & Algorithms

Assignment Help:

Q. By making use of stacks, write an algorithm to determine whether the infix expression has balanced parenthesis or not.                                                                                                               

Ans.

Algorithm parentheses is written below

This specific algorithm reads a source program and parses it to make sure all opening -closing parenthesis are systematically paired

1. loop (more data)

read (character)

if (character is not a closing parenthesis)

pushstack ( stack, character)

else

if (character is closing parenthesis)

popstack (stack, token)

while ( token is not an opening paranthesis)

popstack (stack, token)

endwhile end if

end if end loop

if (not emptystack (stack))

print (Error: opening parenthesis not matched)

end parseparens.


Related Discussions:- Infix expression has balanced parenthesis or not

Search on a hashed file, Write a program to simulate searching over a hashe...

Write a program to simulate searching over a hashed file, with different assumptions for the sizeof file pages.Write a program to perform equality search operations on the hashed f

Encryption the plain-text using the round keys, Encryption the plain-text u...

Encryption the plain-text using the round keys: 1. (Key schedule) Implement an algorithm that will take a 128 bit key and generate the round keys for the AES encryption/decryp

Deletion of a node from an avl tree, For AVL trees the deletion algorithm i...

For AVL trees the deletion algorithm is a little more complicated as there are various extra steps involved in the deletion of node. If the node is not a leaf node, then it contain

Create a function to show data structure, Given a number that is represente...

Given a number that is represented in your data structure, you will need a function that prints it out in base 215 in such a way that its contents can be checked for correctness. Y

Circular queue, explain implementation of circular queue insert,delete oper...

explain implementation of circular queue insert,delete operations

State about the bit string, State about the Bit String Carrier set of...

State about the Bit String Carrier set of the Bit String ADT is the set of all finite sequences of bits, including empty strings of bits, which we denote λ. This set is {λ, 0

General, whats the definition of ADT and data type?

whats the definition of ADT and data type?

Hashing and hash functions, Q. Describe the term hashing. Explain any two u...

Q. Describe the term hashing. Explain any two usually used hash functions. Explain one method of collision resolution.

Process of decision making under uncertainty, (a) Describe the steps involv...

(a) Describe the steps involved in the process of decision making under uncertainty. (b) Explain the following principles of decision making: (i) Laplace, (ii) Hurwicz. (c

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd