0 Comments

Assignment No. 2: Usage of Stack

Subject: Data Structures

Assigned: 2/7/2016

Assignment Marks: 30

Instructor: CS301 Team

Due Date: 2/7/2016

Attached Files: Non

Objective:

The objective of this assignment is to give you some practice regarding usage of Stacks.

Instructions:

1- This is an individual assignment. You will submit your work individually through your logins.

2- Write your name and roll number at the start of the assignment.

3- Do not copy and paste any thing from the internet. Your work must be original.

4- Please note that you must do your own work. If any one found copying from another

student, no marks will be given to him/ her.

5- Deadline for this assignment is 2/7/2016. This deadline will not be extended.

6- No assignment will be accepted through email before and after the due date.

7- If you have any problems, feel free to mail at C..1@vu.edu.pk.

Problems

Question No. 1: (20 marks)

Write a C++ program that takes an infix expression and convert it into a prefix expression.

Note: Your Submission must include:

1. A working MakeFile (Dev-C++ project File).

2. All the Source Code(.h and .cpp files) necessary to compile and run your program.

3. Upload all the files on VULMS in a zip folder.

Note: Use Dev-C++ 4.9.7.0 which is available at VULMS.

Question No. 2: (5 marks)

Apply the evaluation algorithm to evaluate the following postfix expression? Assume , , .

CBA+*ABC-+*

Write each step of this conversion using the following table.

Input

op1

op2

value

stack

Question No. 3: (5 marks)
Convert the following infix expression

(A+B)/(C-(D-E)*F)-G

into postfix expression. Show the trace of the conversion steps, i.e., the stack, the infix expression and postfix expression, using the following table.

Step No.

Stack

Infix

Postfix

Order Solution Now

Categories: