clarify the instructions

This commit is contained in:
Jidong Xiao
2024-04-02 12:14:48 -04:00
parent bf7fe1cda3
commit d1419d776b

View File

@@ -17,24 +17,53 @@ First, read the code of the provided program, and run the program to see its out
- Play this [animation](https://jidongxiao.github.io/CSCI1200-DataStructures/animations/trees/level_order/index.html) to see how level order traverse works. - Play this [animation](https://jidongxiao.github.io/CSCI1200-DataStructures/animations/trees/level_order/index.html) to see how level order traverse works.
Then, replace the STL queue library with the STL stack library, and implement the queue using two stacks. Do not change the *main* function. Do not change the *levelOrderTraversal* function, except this line: The provided program includes the STL queue library with this line:
```cpp
#include <queue>
```
Now, let us assume that the STL queue library is not available, but the STL stack library is avaiable, meaning that you are now not allowed to have this above line in the program, but you can have the following line in the program:
```cpp
#include <stack>
```
Do not change the *main* function. Do not change the *levelOrderTraversal* function, except this line:
```cpp ```cpp
std::queue<TreeNode*> myQueue; std::queue<TreeNode*> myQueue;
``` ```
Can you still make the program work? i.e., still traversing a binary tree by level order, when the STL queue library is not available, but the STL stack library is available to you.
**To complete this checkpoint**: Show a TA your program, and your test results. Your program should still produce the same results as the original program. And you must be able to explain your program. **To complete this checkpoint**: Show a TA your program, and your test results. Your program should still produce the same results as the original program. And you must be able to explain your program.
## Checkpoint 2: ## Checkpoint 2:
*estimate: 30-40 minutes* *estimate: 30-40 minutes*
Re-implement the queue using the STL list library. Still, do not change the *main* function, and do not change the *levelOrderTraversal* function, except this line: Now, let us assume that the STL queue library is not available, and the STL stack library is not avaiable, meaning that you are now not allowed to have either of following two lines in the program:
```cpp
#include <queue>
#include <stack>
```
However, you can include the STL list library like this:
```cpp
#include <list>
```
Still, do not change the *main* function, and do not change the *levelOrderTraversal* function, except this line:
```cpp ```cpp
std::queue<TreeNode*> myQueue; std::queue<TreeNode*> myQueue;
``` ```
Can you still make the program work? i.e., still traversing a binary tree by level order, when neither the STL queue library nor the STL stack library is available, but the STL list library is available to you.
**To complete this checkpoint**: Show a TA your program, and your test results. Your program should still produce the same results as the original program. And you must **To complete this checkpoint**: Show a TA your program, and your test results. Your program should still produce the same results as the original program. And you must
be able to explain your program. be able to explain your program.