Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Data Strcuture Lab - 05 AIUB

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 9

Applications of Stack & Queue

Course Code: CSC 2107 Course Title: Data Structure (Lab)

Dept. of Computer Science


Faculty of Science and Technology

Lecturer No: 4 Week No: 4 Semester:


Lecturer: Name & email
Lecture Outline

1. Rules & Guidelines


2. Lab Tasks
i. Instructions to Follow
3. Prerequisites
4. Objectives
5. Books
6. References
Rules & Guidelines

Write your own rules to evaluate lab tasks.​


Lab Tasks

1. Write C++ code to convert an infix algebraic expression to a postfix one using the help
of Stack & Queue.
2. Write C++ code to evaluate a given postfix algebraic expression using the help of Stack
& Queue.

For both of these problems, an operand is assumed to be a single digit. And an operator is
limited to ‘+’, ‘-’, ‘*’, ‘/’ (these 4 types). Also, for usage of parentheses, use
only ‘(‘ for opening and ‘)’ for closing.

In light of these remarks, an algebraic expression for example can be written like below:

2*4+(6-3)/3

Follow the instructions from the next slide regarding how to approach the problems 1 and
2.
Instructions to Follow

 You are provided with the implementations of Stack and Queue as header files in
your student portal. You will find a zip file containing them.

 Download the zip file and use the header files inside for solving problems 1 & 2.

 Use the help of the pseudo codes with simulations for both the infix to postfix
conversion and postfix evaluation stated in Theory Lecture 4.2.

 Hint: Algebraic expressions in your program can be written as a string.

Home Task:

 Use a stack to reverse a string input by the user. Output the reversed string.
Prerequisites

 Have a clear and full understanding of the implementation of Stack & Queue in C++.

 Theory Lecture 4.2.


Objectives

 To learn how to approach a problem in order to solve it using stack & queue.

 To recognize the need of LIFO (Last In First Out) and/or FIFO (First In First Out)
mechanism in a problem.
Books

 “Schaum's Outline of Data Structures with C++”. By John R. Hubbard


 “Data Structures and Program Design”, Robert L. Kruse, 3rd Edition, 1996.
 “Data structures, algorithms and performance”, D. Wood, Addison-Wesley, 1993
 “Advanced Data Structures”, Peter Brass, Cambridge University Press, 2008
 “Data Structures and Algorithm Analysis”, Edition 3.2 (C++ Version), Clifford A.
Shaffer, Virginia Tech, Blacksburg, VA 24061 January 2, 2012
 “C++ Data Structures”, Nell Dale and David Teague, Jones and Bartlett Publishers,
2001.
 “Data Structures and Algorithms with Object-Oriented Design Patterns in C++”,
Bruno R. Preiss,
References
1. Theory Lecture 4.2 of this course.

You might also like