Data Structures and Algorithms
Data Structures and Algorithms
Tutorial
Module 2
TOPICS: Stacks & Queues
1. Given a stack, how to reverse the elements of stack using only stack operations
(push & pop)?
2. Show how to implement one queue efficiently using two stacks. Analyze the running
time of queue operations.
3. Show how to implement one stack efficiently using two queues. Analyze the running
time of stack operations.
4. How do we implement 2 stacks using only one array? ( Hint: Our stack routines
should not indicate an exception unless every slot in the array is used.)
5. Write a program to find the transpose of a sparse matrix.
6. Discuss upon the different types of queues used in programming and point out the
scenarios in which each of those queues would be useful.
7. Write an algorithm to perform addition of two polynomials, represented using
arrays.