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. If you need help, please post a question on Piazza, or contact the professor.
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:
For each problem you have to solve, the solution should be written in a function that has the input / output behavior described in the problem.
Important: submit your solution to all problems in a single project called PrgAsst07. Each problem should have its own .h and .cpp file, and make sure that the names of the functions and classes, as well as the input / output behavior of the functions is exactly as described in this page.
Write a function decodeText
that two strings as input, an input file name, and an output file name, and returns nothing. The function should read the input file character by character, and decode it as follows:
After reading the entire input file, the decoded text should be written in the output file. However, your program should not crash or even open the output file if any of the following happen:
You can find files that you can use to test your program here.
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.
If you want to use the STL implementation of queues, you should 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.
If you want to use the STL implementation of stacks, you should note that no assignment operator is implemented, so copies of stacks 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.