re org the paragraphs
This commit is contained in:
@@ -1,12 +1,8 @@
|
|||||||
# Lab 12 — Stacks and Queues
|
# Lab 12 — Stacks and Queues
|
||||||
|
|
||||||
In this lab, you will implement queues in different ways, and then fix memory leaks in the provided program.
|
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), and then turn off all network connections.
|
||||||
|
|
||||||
## Checkpoint 1:
|
The provided program [levelOrder.cpp](levelOrder.cpp) traverses a binary tree by level order. It prints the following message to STDOUT:
|
||||||
|
|
||||||
*estimate: 30-40 minutes*
|
|
||||||
|
|
||||||
Form a team of two members. This [levelOrder.cpp](levelOrder.cpp) program 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
|
||||||
@@ -14,22 +10,26 @@ 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
|
||||||
```
|
```
|
||||||
|
|
||||||
Read the code, and then run the program to see its output. After that, 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:
|
## Checkpoint 1:
|
||||||
|
|
||||||
|
*estimate: 30-40 minutes*
|
||||||
|
|
||||||
|
Form a team of two members. Read the code of provided program, and then run the program to see its output. After that, 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:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
queue<TreeNode*> myQueue;
|
std::queue<TreeNode*> myQueue;
|
||||||
```
|
```
|
||||||
|
|
||||||
**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: 40-50 minutes*
|
*estimate: 30-40 minutes*
|
||||||
|
|
||||||
Form a new team of two members. 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:
|
Form a new team of two members. 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:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
queue<TreeNode*> myQueue;
|
std::queue<TreeNode*> myQueue;
|
||||||
```
|
```
|
||||||
|
|
||||||
**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
|
||||||
|
|||||||
Reference in New Issue
Block a user