Slide 1

Slide 1 text

Linked Lists Week 3 What’s a good memory you have from this week? -> I had an amazingly tasty burger 🍔

Slide 2

Slide 2 text

Addressing Feedback - Panel was well-received - Office hours are posted on course portal now - Zoom issues should be resolved

Slide 3

Slide 3 text

Linked Lists

Slide 4

Slide 4 text

What is a Linked List? Individual elements (nodes) that each hold two pieces of information: 1) data (integer, string, anything!) 2) reference to the next node

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

Why are they useful?

Slide 7

Slide 7 text

Why are they useful? Web browser’s history (previous / next page)

Slide 8

Slide 8 text

Why are they useful? Web browser’s history (previous / next page) Memory management (blocks of memories)

Slide 9

Slide 9 text

Why are they useful? Web browser’s history (previous / next page) Memory management (blocks of memories) Hash tables (resolving collisions)

Slide 10

Slide 10 text

Types of Linked Lists

Slide 11

Slide 11 text

Singly linked Doubly linked Circularly linked Types of Linked Lists

Slide 12

Slide 12 text

Singly linked Doubly linked Circularly linked Types of Linked Lists

Slide 13

Slide 13 text

Pros and Cons Always think about space / time complexity when choosing a data structure!

Slide 14

Slide 14 text

Pros and Cons Always think about space / time complexity when choosing a data structure! Good for:
 - insertion / deletion from one end 
 


Slide 15

Slide 15 text

Pros and Cons Always think about space / time complexity when choosing a data structure! Good for:
 - insertion / deletion from one end 
 
 Bad for:
 - searching

Slide 16

Slide 16 text

Pros and Cons Always think about space / time complexity when choosing a data structure! Good for:
 - insertion / deletion from one end 
 
 Bad for:
 - searching https://guides.codepath.org/compsci/Linked-Lists

Slide 17

Slide 17 text

Linked List Tips and Tricks

Slide 18

Slide 18 text

Linked List Tips and Tricks Take multiple passes through the linked list
 - get length 
 - save other information about contents

Slide 19

Slide 19 text

Linked List Tips and Tricks Take multiple passes through the linked list
 - get length 
 - save other information about contents Two pointers
 - ‘race car’ strategy with one regular pointer, and one fast pointer

Slide 20

Slide 20 text

Linked List Tips and Tricks Take multiple passes through the linked list
 - get length 
 - save other information about contents Two pointers
 - ‘race car’ strategy with one regular pointer, and one fast pointer Dummy node
 - helpful for preventing errors when returning ‘head’ (merging lists, deleting from lists)

Slide 21

Slide 21 text

Understand Match Pseudocode / Plan Implement Review Evaluate

Slide 22

Slide 22 text

Plan / Pseudocode Start to figure out how you would solve the problem Can you create any ‘magic’ helper methods that would simplify the solution? (ie : getLength(), reverse() ) Talk through different approaches you can take, and their tradeoffs Be able to verbally describe your approach and explain how an example input would produce the desired output

Slide 23

Slide 23 text

Example: Remove Nth Node from End of List Understand: Always start by understanding the question and running through an example

Slide 24

Slide 24 text

Example: Remove Nth Node from End of List Understand: Always start by understanding the question and running through an example 1->2->3->4->5, n = 2


Slide 25

Slide 25 text

Example: Remove Nth Node from End of List Understand: Always start by understanding the question and running through an example 1->2->3->4->5, n = 2
 return 1->2->3->5

Slide 26

Slide 26 text

Example: Remove Nth Node from End of List Understand: Always start by understanding the question and running through an example 1, n = 1


Slide 27

Slide 27 text

Example: Remove Nth Node from End of List Understand: Always start by understanding the question and running through an example 1, n = 1
 return null

Slide 28

Slide 28 text

Example: Remove Nth Node from End of List Understand: Always start by understanding the question and running through an example 1->2->3->4->5, n = 2
 return 1->2->3->5 Let’s assume we start without any time / space constraints. So our goal is to figure out ANY kind of solution to produce the right answer Any other questions??

Slide 29

Slide 29 text

Example: Remove Nth Node from End of List Match : Are there any special techniques that we can use to help make this easier?
 


Slide 30

Slide 30 text

Example: Remove Nth Node from End of List Match : Are there any special techniques that we can use to help make this easier?
 -> We can take a first pass through the linked list to store the elements in an array 
 


Slide 31

Slide 31 text

Example: Remove Nth Node from End of List Match : Are there any special techniques that we can use to help make this easier?
 -> We can take a first pass through the linked list to store the elements in an array 
 -> We can also take a pass to get the length of the linked list 


Slide 32

Slide 32 text

Example: Remove Nth Node from End of List Match : Are there any special techniques that we can use to help make this easier?
 -> We can take a first pass through the linked list to store the elements in an array 
 -> We can also take a pass to get the length of the linked list Plan : What are some different ways we can solve this problem?
 


Slide 33

Slide 33 text

Example: Remove Nth Node from End of List Match : Are there any special techniques that we can use to help make this easier?
 -> We can take a first pass through the linked list to store the elements in an array 
 -> We can also take a pass to get the length of the linked list Plan : What are some different ways we can solve this problem?
 1) We can store the elements in an array, get the length of the array, and then rebuild our list excluding the nth to last node
 


Slide 34

Slide 34 text

Example: Remove Nth Node from End of List Match : Are there any special techniques that we can use to help make this easier?
 -> We can take a first pass through the linked list to store the elements in an array 
 -> We can also take a pass to get the length of the linked list Plan : What are some different ways we can solve this problem?
 1) We can store the elements in an array, get the length of the array, and then rebuild our list excluding the nth to last node
 2) We can follow the first idea, but instead of storing things in an array, remove the reference to the nth to last node the second time we iterate through the list


Slide 35

Slide 35 text

Example: Remove Nth Node from End of List Match : Are there any special techniques that we can use to help make this easier?
 -> We can take a first pass through the linked list to store the elements in an array 
 -> We can also take a pass to get the length of the linked list Plan : What are some different ways we can solve this problem?
 1) We can store the elements in an array, get the length of the array, and then rebuild our list excluding the nth to last node
 2) We can follow the first idea, but instead of storing things in an array, remove the reference to the nth to last node the second time we iterate through the list
 What would be the space / time complexity of our solution?

Slide 36

Slide 36 text

Example: Remove Nth Node from End of List Our approach:
 1) make initial pass through linked list to get length
 2) make second pass to remove any reference to nth to last node
 


Slide 37

Slide 37 text

Example: Remove Nth Node from End of List Our approach:
 1) make initial pass through linked list to get length
 2) make second pass to remove any reference to nth to last node
 
 Let’s draw out how this might work with an example
 Given linked list 1->2->3, n = 1 (we want to return 1->2)

Slide 38

Slide 38 text

Example: Remove Nth Node from End of List Our approach:
 1) make initial pass through linked list to get length
 2) make second pass to remove any reference to nth to last node
 
 Let’s draw out how this might work with an example
 Given linked list 1->2->3, n = 1 (we want to return 1->2) First pass, we get length = 3.
 


Slide 39

Slide 39 text

Example: Remove Nth Node from End of List Our approach:
 1) make initial pass through linked list to get length
 2) make second pass to remove any reference to nth to last node
 
 Let’s draw out how this might work with an example
 Given linked list 1->2->3, n = 1 (we want to return 1->2) First pass, we get length = 3. Since n = 1, that means we want to remove the 3 -1 = 2 node (with index starting at 0)
 


Slide 40

Slide 40 text

Example: Remove Nth Node from End of List Our approach:
 1) make initial pass through linked list to get length
 2) make second pass to remove any reference to nth to last node
 
 Let’s draw out how this might work with an example
 Given linked list 1->2->3, n = 1 (we want to return 1->2) First pass, we get length = 3. Since n = 1, that means we want to remove the 3 -1 = 2 node (with index starting at 0)
 
 As we iterate through the list..
 at node 1 -> numberOfNodesSeen = 0

Slide 41

Slide 41 text

Example: Remove Nth Node from End of List Our approach:
 1) make initial pass through linked list to get length
 2) make second pass to remove any reference to nth to last node
 
 Let’s draw out how this might work with an example
 Given linked list 1->2->3, n = 1 (we want to return 1->2) First pass, we get length = 3. Since n = 1, that means we want to remove the 3 -1 = 2 node (with index starting at 0)
 
 As we iterate through the list..
 at node 1 -> numberOfNodesSeen = 0
 at node 2-> numberOfNodesSeen = 1

Slide 42

Slide 42 text

Example: Remove Nth Node from End of List Our approach:
 1) make initial pass through linked list to get length
 2) make second pass to remove any reference to nth to last node
 
 Let’s draw out how this might work with an example
 Given linked list 1->2->3, n = 1 (we want to return 1->2) First pass, we get length = 3. Since n = 1, that means we want to remove the 3 -1 = 2 node (with index starting at 0)
 
 As we iterate through the list..
 at node 1 -> numberOfNodesSeen = 0
 at node 2-> numberOfNodesSeen = 1
 at node 3 -> numberOfNodesSeen = 2 -> at this point we need to set node 2’s next to be node 3’s next!

Slide 43

Slide 43 text

Example: Remove Nth Node from End of List Our approach:
 1) make initial pass through linked list to get length
 2) make second pass to remove any reference to nth to last node
 
 Let’s draw out how this might work with an example
 Given linked list 1->2->3, n = 1 (we want to return 1->2) First pass, we get length = 3. Since n = 1, that means we want to remove the 3 -1 = 2 node (with index starting at 0)
 
 As we iterate through the list..
 at node 1 -> numberOfNodesSeen = 0, previousNode = null
 at node 2-> numberOfNodesSeen = 1, previousNode = 1
 at node 3 -> numberOfNodesSeen = 2, previousNode = 2 -> we set previousNode.next = node.next (node 3’s next = null)

Slide 44

Slide 44 text

Breakout Rooms - Turn on your camera - Assign a timekeeper
 - Breakout rooms will close at 11:30 am PT
 - Take a 5 min break right before then! - Open the Course Portal and go to this week’s Session #2 tab
 - Read the At a Glance
 - Start with the Icebreaker! - If your pod needs help, post a message in the @se102-help-fall21 slack channel and tag @se102-tas

Slide 45

Slide 45 text

Evaluating companies

Slide 46

Slide 46 text

Evaluating companies Glassdoor reviews Researching current people who work at the company on LinkedIn

Slide 47

Slide 47 text

Questions for me?

Slide 48

Slide 48 text

Questions for me? Work Life Balance

Slide 49

Slide 49 text

Questions for me? Work Life Balance - How does the team figure out what to work on in the next 3-6 months? - How does the team tackle tech debt? - What is a typical release process? - Weekly? Biweekly? - How does the team prepare for releases? - How is the release monitored afterwards? - Are there oncall schedules?

Slide 50

Slide 50 text

Questions for me? Career Growth

Slide 51

Slide 51 text

Questions for me? Career Growth - What do you see me working on in my first 3-6 months on the job? - How do people on the team get feedback usually?

Slide 52

Slide 52 text

Questions for me? General - What are some challenging projects you’ve worked on in the past 3-6 months? - What kind of meetings do you usually have in a week?

Slide 53

Slide 53 text

Questions for me? Other questions?

Slide 54

Slide 54 text

Survey