Lab04 - Stacks & Queues
You will need solutions of Lab03 exercises to complete this week exercises.
Exercise 1
Based on an implementation of singly-linked list from last week exercises, implement a stack (of strings) providing basic operations: push, pop, getSize, top, isEmpty, print.
You can use this sample implementation if you wish.
You should write a small program to test all the methods.
Exercise 2
A stack (of strings) can be implemented using an existing singly-linked list data structure, i.e. a stack contains a list as its only data component, which takes care of the detailed list processing.
Complete this implemetation. (You need this singly-linked list to compile the code)
Exercise 3
Implement a queue (of strings) in the same way as the stack in Exercise 2.
Exercise 4
Now that you have implemented Stack and Queue data structures, write a small program to demonstrate your solution to Question 4, Homework 4.
Exercise 5
Compile and run this STL's stack example: stl-stack-exx.cpp.
Modify the program to push and pop the characters 'a', 'b', ...,'e' instead of numbers 0..4.
Modify the program to read a string of parentheses from the keyboard then use a stack data structure to determine if the string is syntactically correct.
Exercise 6
Look up cplusplus.com for an example program that uses the standard library queue data structure. Compile and run the program.