We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>


Looking For Something at vustudents.ning.com? Click Here to Search

CS301 Data Structures Assignment No 02 Solution & Discussion Spring 2019 Due Date: May 30, 2019

Share Your Solutions!

Share This With Friends......

+ Click Here To Join also Our facebook study Group.

This Content Originally Published by a member of VU Students.

+ Prohibited Content On Site + Report a violation + Report an Issue


..How to Join Subject Study Groups & Get Helping Material?..


Views: 1185

See Your Saved Posts Timeline

Attachments:

Replies to This Discussion

Please Discuss here about this assignment.Thanks

Our main purpose here discussion not just Solution

We are here with you hands in hands to facilitate your learning and do not appreciate the idea of copying or replicating solutions. Read More>>

Discussed & be touched with this discussion. After discussion a perfect solution will come in a result at the end.

 

“How to Join Subject Study Groups & Get Helping Material”

 

P.S:    Please always try to add the discussion in proper format title like “CS101 Assignment / GDB No 01 Solution & Discussion Due Date: ___________”

 

Share below link with friends for solution & Discussion. A Single link for help in your education.

http://bit.ly/vucodes

solution 

CS301 Assignment 2 2019 complete, PostFix Expression Evaluation using Stack

Cs301 2nd assignment solution Spring 2019

Attachments:

CS301 Assignment 2 Solution Spring 2019

Problem Statement

 

You are required to write a program in C++ to implement Stack data structure and use this data structure to evaluate Postfix expression. You have to implement Stack data structure using doubly linked list. A stack is a LIFO structure in which data elements are stored in an order such that last element pushed on the stack will be popped up first.

 

The Stack data structure will be implemented in such way so that Nodes will be added and removed at the end of link list. In this case, head node will point to most recent element. After popping elements from Stack, head will move to previous Node.

 

After implementing Stack data structure, you will now use this data structure to evaluate postfix expression.

 

 

Detailed Description:

 

Implementation of Stack using linked memory (Doubly linked list):

 

You will implement Stack using class. The Stack class will have following member functions:

 

Function

Description

push()

This method will push data elements on Stack. So, the head node will point to the top of stack.

 

pop()

This method will remove elements from Stack. This will display the value and then will delete the node from Stack. After deleting node, the head will move to previous Node in the stack.

 

top()

This method will retrieve the value of top Node of the stack without deleting the node.

 

isEmpty()

This method will check if the Stack is empty or not.

 

 

The Stack class will have data members and constructor which you will define accordingly.

The Stack class will use Node class to add, remove and retrieve nodes in the stack.

 

 

You can see from the below pictures, when a new node is pushed on the stack, the head node moves forward and points to most recent Node.

 

 

 

 

 

 

 

 

As the head is pointing to most recent element containing data element 8, so after pop() operation, the node will be removed from the stack and head will point to previous node containing value 6as shown below:

 

Note: As the head node will now point to previous node so in that case, information regarding address of previous node may be needed. So, make sure to implement Stack by keeping in mind the address of previous nodes like in the case of doubly linked list.

 

 

 

After another pop() operation, the node will be removed from the stack and head will point to previous node containing value 2 as shown below:

 

 

 

 

Evaluating Postfix expression:

 

After implementing Stack data structure, you can now evaluate postfix expression by using stack.

You will define a evaluatePostfix() method which will take a postfix expression. This method will display the length of expressionand a value after evaluating this expression.

 

 

 

 

 

 

Detail of main() method:

 

In main() method, user will declare three postfix expressions and then will pass these expressions to evaluatePostfix()method which will display the length of postfix expressions and then display the value after evaluating this expression.

 

 

The first expression should be43+5* and its evaluated value will be 35.

The second expression should be 435*+ and its evaluated value will be 19.

The third expression should be623+-382/+*2^3+and its evaluated value will be 52.

 

 

 

Sample screenshots of program:

 

cs301 assignment no.2 solution

Attachments:

RSS

Study Corner For DigiSkills Students

© 2019   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service