Question: A Stack is a linear data structure that follows the LIFO (Last-In-First-Out) principle. (a) Suppose we are using the usual node definition (with data member

 A Stack is a linear data structure that follows the LIFO

A Stack is a linear data structure that follows the LIFO (Last-In-First-Out) principle. (a) Suppose we are using the usual node definition (with data member called data and link) to create a stack of integer numbers. Your program is using a pointer of type node called top to point to the top node of a stack. Write C++ statements that will insert the new item into the stack. During insertion operation, do consider the condition of the stack whether it is empty or not. (5 marks) (b) Among the common applications that apply stack concept are arithmetic conversion and arithmetic evaluation. i. Use the postfix evaluation algorithm to evaluate the following postfix expression. Show the content of the stack each time you scan a new token from the expression: 2, 5, *, 4, +, 6, 2, 7, - (10 marks) ii. Use the infix to postfix algorithm to transform the following expressions into its postfix form. Show the content of the stack and postfix list each time you scan a new token from the expression: (A + B) / C* (D - E * F) (10 marks) [25 Mark]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!