From 0879ec2a5b94e43e690656beb085361936f06787 Mon Sep 17 00:00:00 2001 From: Zoe Farrell Date: Tue, 2 Jan 2024 12:47:17 -0700 Subject: [PATCH 1/4] First draft of stacks and queues lesson --- module6/lessons/Week4/StacksAndQueues.md | 57 ++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 module6/lessons/Week4/StacksAndQueues.md diff --git a/module6/lessons/Week4/StacksAndQueues.md b/module6/lessons/Week4/StacksAndQueues.md new file mode 100644 index 0000000..22fed57 --- /dev/null +++ b/module6/lessons/Week4/StacksAndQueues.md @@ -0,0 +1,57 @@ +--- +layout: page +title: Stacks and Queues - CS Topic - Data Structure +--- + +## Introduction + +Today's lesson on Stacks and Queues will be a mixture of independent research, class walkthrough and discussion, and diving into code implementations. + +### Independent Learning +Start by taking 30 minutes to independently research the Stack and Queue Data Structures. + +I recommend that you start by reading these two articles: +* [Stacks and Overflows](https://medium.com/basecs/stacks-and-overflows-dbcf7854dc67#.3l76d12dq)) +* [Difference between Stacks and Queues](https://www.geeksforgeeks.org/difference-between-stack-and-queue-data-structures/) + +As you're researching, look for the answers to the following questions. + +1. What are the key operations that can be done on a Stack, what about for a Queue? +1. What is similar between Stacks and Queues? +1. What is different between Stacks and Queues? +1. What are examples of Stacks and Queues "in the wild"? + +Also, start thinking about how you would use a LinkedList or an Array to build a Stack or a Queue. We will dig more into implementation in the next section! + +## Walkthroughs and Code +### Stacks + +The Stack Data Structure can be implemented using either an Array or a Linked List. For today, we are going to implement a Stack using an Array and it will overflow if the Stack is larger than 10. + + + + +Fork [this](https://replit.com/@Zoe-Farrell/Stack-Array-Implementation) repl. With your partner read through the code. Try your best to understand what each line does and determine the Big O time complexity of the operations implemented. + + +Hungry for more? Try implementing the other key Stack methods: Peek, Size, and IsEmpty! + +### Queues + +The Queue Data Structure can be implemented using either an Array or a Linked List. For today, we are going to implement a Queue using a Linked List that keeps track of both the start and end of the list. + + + +Fork [this](https://replit.com/@Zoe-Farrell/Queue-List-Implementation) repl. With your partner read through the code. Try your best to understand what each line does and determine the Big O time complexity of the operations implemented. + + +Hungry for more? Try implementing the other key Queue methods: Peek, Size, and IsEmpty! + + + From 265c871fc2698ab7aaf441f5d43dd5feb4aba32b Mon Sep 17 00:00:00 2001 From: Zoe Farrell Date: Tue, 2 Jan 2024 12:49:25 -0700 Subject: [PATCH 2/4] Add stacks and queues to index --- module6/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/module6/index.md b/module6/index.md index c61f278..f8d9a7b 100644 --- a/module6/index.md +++ b/module6/index.md @@ -40,3 +40,4 @@ In Module 6, students will begin to dive into the skills and mindsets necessary ### Week 4 * [Revisiting the STAR Method](./lessons/Week4/RevisitingSTAR) +* [Stacks and Queues](./lessons/Week4/StacksAndQueues) From ae4c2e323bd454fb67e330005ebf47ea7ce5fac4 Mon Sep 17 00:00:00 2001 From: Zoe Farrell Date: Tue, 2 Jan 2024 12:50:36 -0700 Subject: [PATCH 3/4] Remove extra paren --- module6/lessons/Week4/StacksAndQueues.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module6/lessons/Week4/StacksAndQueues.md b/module6/lessons/Week4/StacksAndQueues.md index 22fed57..213c388 100644 --- a/module6/lessons/Week4/StacksAndQueues.md +++ b/module6/lessons/Week4/StacksAndQueues.md @@ -11,7 +11,7 @@ Today's lesson on Stacks and Queues will be a mixture of independent research, c Start by taking 30 minutes to independently research the Stack and Queue Data Structures. I recommend that you start by reading these two articles: -* [Stacks and Overflows](https://medium.com/basecs/stacks-and-overflows-dbcf7854dc67#.3l76d12dq)) +* [Stacks and Overflows](https://medium.com/basecs/stacks-and-overflows-dbcf7854dc67#.3l76d12dq) * [Difference between Stacks and Queues](https://www.geeksforgeeks.org/difference-between-stack-and-queue-data-structures/) As you're researching, look for the answers to the following questions. From 77fc9cc3eac775c51cca0410b0656217339c1005 Mon Sep 17 00:00:00 2001 From: Zoe Farrell Date: Tue, 2 Jan 2024 13:10:48 -0700 Subject: [PATCH 4/4] Update stacks and queues based on feedback --- module6/lessons/Week4/StacksAndQueues.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/module6/lessons/Week4/StacksAndQueues.md b/module6/lessons/Week4/StacksAndQueues.md index 213c388..a1a9f30 100644 --- a/module6/lessons/Week4/StacksAndQueues.md +++ b/module6/lessons/Week4/StacksAndQueues.md @@ -7,13 +7,14 @@ title: Stacks and Queues - CS Topic - Data Structure Today's lesson on Stacks and Queues will be a mixture of independent research, class walkthrough and discussion, and diving into code implementations. -### Independent Learning +## Independent Learning Start by taking 30 minutes to independently research the Stack and Queue Data Structures. I recommend that you start by reading these two articles: * [Stacks and Overflows](https://medium.com/basecs/stacks-and-overflows-dbcf7854dc67#.3l76d12dq) * [Difference between Stacks and Queues](https://www.geeksforgeeks.org/difference-between-stack-and-queue-data-structures/) +
As you're researching, look for the answers to the following questions. 1. What are the key operations that can be done on a Stack, what about for a Queue? @@ -22,6 +23,19 @@ As you're researching, look for the answers to the following questions. 1. What are examples of Stacks and Queues "in the wild"? Also, start thinking about how you would use a LinkedList or an Array to build a Stack or a Queue. We will dig more into implementation in the next section! +
+ + +## Arrays and Linked Lists Review + +
+With your partner discuss the following questions: + +1. What do you remember about Arrays? +1. What do you remember about Linked Lists? +1. Why might these both be useful for building Stacks and Queues? (Might be helpful to think about why a dictionary would not be helpful here) +
+ ## Walkthroughs and Code ### Stacks