Whether the infix expression has balanced parenthesis or not, Data Structure & Algorithms

Assignment Help:

Using stacks, write an algorithm to determine whether the infix expression has balanced parenthesis or not

Algorithm parseparens

This algorithm reads a source program and parses it to make sure all opening -

closing parenthesis are 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:- Whether the infix expression has balanced parenthesis or not

Advantage of list over arrays, The advantage of list over Arrays is flexibi...

The advantage of list over Arrays is flexibility. Over flood is not a problem until the computer memory is bushed. When the individual record are quite large, it may be difficult t

Discuss the properties of adt, Question 1 Write a program in 'C' to rea...

Question 1 Write a program in 'C' to read N numbers and print them in descending order Question 2 Discuss the properties of ADT Question 3 Write a note on

An undirected graph g with n vertices and e edges, An undirected graph G wi...

An undirected graph G with n vertices and e edges is shown by adjacency list.  What is the time required to generate all the connected components? O (e+n)

Algorithms & flowchart, write an algorithm to find the average number of oc...

write an algorithm to find the average number of occurances of MECHANIL in an english passage

Explain how the shuttle sort algorithm works, Question 1 Explain how th...

Question 1 Explain how the shuttle sort algorithm works by making use of the following list of integers:11, 4, 2, 8, 5, 33, 7, 3, 1, 6. Show all the steps. Question 2

Enumerate the types in ruby, Enumerate the Types in Ruby Ruby is a pure...

Enumerate the Types in Ruby Ruby is a pure object-oriented language, meaning that all types in Ruby are classes, and each value in a Ruby program is an instance of a class. Thi

Interest rate, explain the determination of interest rate in the classical ...

explain the determination of interest rate in the classical system.

Graph, For the following graph find the adjacency matrix and adjacency list...

For the following graph find the adjacency matrix and adjacency list representation of the graph.

Mapping constain, one to many one to one many to many many to one

one to many one to one many to many many to one

Algorithms, Write an algorithm to print all even numbers in descending orde...

Write an algorithm to print all even numbers in descending order and draw the flowchart

5/11/2013 1:31:02 AM

Thanks for suggesting me this answer, appreciate your knowledge. 

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