Anda di halaman 1dari 2

Data Structures and Algorithms

Assignment No. 03
Instructions:

1. The aim of this assignment is to give you initial understanding of the implementation of
Queue and Stack Data Structures.
2. You will have maximum marks if you have done all of the tasks.
3. Submit your assignment folder on Google Classroom in a single compressed (.zip, .rar)
folder. Folder should be named as RollNo_Assignment_No. It should contain:
1) .docx file containing codes. Paste all the required codes in the .docx file.
2) Perfectly working .exe files of your codes.
4. You can submit only electronic copy, hand written assignment would not be accepted.
5. Discussion among students is allowed but the final solution of the assignment should be
individual.
6. Cheating from others or the internet could result in zero marks in assignment to an F in
the course.
7. Deadline to submit this assignment is Wednesday, October 25, 2017 11:59 pm on
Google Classroom.
8. Late submission within 12 hours of the deadline will be penalized 50% of score. After
that submission will not be graded.

Question no. 1:

Write a code that evaluates an infix expression by converting it into a postfix expression. Your
code should print all the steps of:

1) Conversion of an infix expression to a postfix expression (as done in class).


2) Evaluation of postfix expression (as done in class).

You can refer to book page # 160 for precedence rules (You are required to implement your
code for only first three rows of table on page # 160, no need to implement logical operators).
Your code should work for the following and similar expressions:

1) A*B* (C/D+EF*G)/HI
2) A++ * B
3) A * B ++
4) A+B++
Question no. 2:

Implement Queue of a printer using circular array. It should have a simple user interface that
gives the user a choice between different operations that can be performed on the queue. For
example:

1) Enter 1 if you want to print queue.


2) Enter 2 if you want to add an element in the queue (Enqueue()).

If I enter 2, it should ask for the input I want to insert in the queue. After adding the element it
should again provide me with the list of operations. This Time if I enter 1, it should print queue
with the new element added in it. It should perform (atleast) following operations:

1) Print() //Print the queue


2) Enqueue( x ) // Insert x
3) Dequeue() //Return and remove least recently inserted item
4) isEmpty() //Return true if empty, else false
5) isFull() //Return true if full, else false
6) makeEmpty() //Remove all items

Your program should be able to expand circular array if the isFull() function returns true.

Anda mungkin juga menyukai