adding hints that they can implement their own functions or classes

This commit is contained in:
Jidong Xiao
2024-04-03 11:53:44 -04:00
parent 657d97fa16
commit f4d39548bb

View File

@@ -1,6 +1,6 @@
# Lab 11 — Stacks and Queues # Lab 11 — Stacks and Queues
In this lab, you will implement queues in different ways, and then fix memory leaks in the provided program. Start by downloading the provided program [levelOrder.cpp](levelOrder.cpp). The provided program [levelOrder.cpp](levelOrder.cpp) traverses a binary tree by level order. It prints the following message to STDOUT: In this lab, you will find out the answer to this question: When the STL queue library/class is not available to you, can you make your own queue? More specifically, in this lab, you will implement queues in different ways, and then fix memory leaks in the provided program. Start by downloading the provided program [levelOrder.cpp](levelOrder.cpp). The provided program [levelOrder.cpp](levelOrder.cpp) traverses a binary tree by level order. It prints the following message to STDOUT:
```console ```console
Level Order Traversal: 1 2 3 4 5 6 7 Level Order Traversal: 1 2 3 4 5 6 7
@@ -8,7 +8,6 @@ Level Order Traversal: 1 2 3 4 5 6 7 8 9
Level Order Traversal: 1 2 3 4 5 6 7 8 Level Order Traversal: 1 2 3 4 5 6 7 8
``` ```
## Checkpoint 1: ## Checkpoint 1:
*estimate: 30-40 minutes* *estimate: 30-40 minutes*
@@ -35,7 +34,7 @@ Do not change the *main* function. Do not change the *levelOrderTraversal* funct
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. 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. You can implement your own classes or functions.
**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.
@@ -62,7 +61,7 @@ Still, do not change the *main* function, and do not change the *levelOrderTrave
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. 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. You can implement your own classes or functions.
**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.