This is an individual assignment. You must complete this lab on your own, although you may discuss lab concepts with other students. Please keep the Academic Integrity Policy in mind---do not show your code to anyone outside of the professors and ninjas, and do not look at anyone else's code for this lab.
The goal of this lab is to introduce you to review some of the concepts we have covered since the beginning of class and to prepare you for the first test. The concepts we review are:
Write a class WeirdIntStack that implements our stack ADT, but which is only allowed to use queues in the implementation. Your implementation is not allowed to use objects of any kind other than queues and you are not allowed to use arrays. Integer-type variables are allowed.
The class should contain the following:
getSize
, isEmpty
, push
, pop
and getTop
that have the effect described in our ADT.pop
and getTop
run in $O(1)$ time. I have no other requirements on the other methods, except that they should not be unnecessarily slow.
You should use the STL implementation of queues. Note that no assignment operator is implemented, so copies of queues must be made manually.
Hint: You should only need one queue in your class member variables, but some of your methods will require an additional queue as temporary storage.
This problem is essentially a mirror image of the previous one. Write a class WeirdIntQueue that implements our queue ADT, but which is only allowed to use stacks in the implementation.
The class should contain the following:
getSize
, isEmpty
, enqueue
, dequeue
and getFront
that have the effect described in our ADT.dequeue
and getFront
run in $O(1)$ time. I have no requirements on the other methods except that they should not be unnecessarily slow.
You should use the STL implementation of stacks. Note that no assignment operator is implemented, so copies of queues must be made manually.
I will assign minor penalties for poor commenting and coding
style.
Please review the Comp 116 Coding
Style for good C++ style.
Submit a .zip file containing the entire project folder for the programming assignment using the submission link on onCourse.