Linked Nodes and Memory Concepts in Summer 2023

Linked Nodes and Memory Concepts in Summer 2023
Slide Note
Embed
Share

This content showcases various images and code snippets related to linked nodes, agenda references, memory concepts, and coding problems for Lesson 2 in Summer 2023. Explore visual representations of contiguous vs. non-contiguous memory, practice sessions with ListNode, and understand the transformation of linked node structures. Dive into the interactive lessons presented with descriptive images and practical examples.

  • Linked Nodes
  • Memory Concepts
  • Summer 2023
  • Coding Problems
  • ListNode

Uploaded on Apr 22, 2025 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Linked Nodes Hitesh Boinpally Summer 2023

  2. Agenda References Review Linked Nodes Practice w/ ListNode Lesson 2 - Summer 2023 2

  3. Agenda References Review Linked Nodes Practice w/ ListNode Lesson 2 - Summer 2023 3

  4. sli.do code: #su_cse123 References (sli.do) Point p = new Point(1, 2); Point q = p; How does the picture change when the second line is executed? Lesson 2 - Summer 2023 4

  5. References Recall that variables store references Don t store the actual object Can think of references as phone numbers Lesson 2 - Summer 2023 5

  6. Agenda References Review Linked Nodes Practice w/ ListNode Lesson 2 - Summer 2023 6

  7. Contiguous vs. Non Contiguous Memory Contiguous Sequential, implicitly connected together 8 12 -3 51 Lesson 2 - Summer 2023 7

  8. Contiguous vs. Non Contiguous Memory Contiguous Sequential, implicitly connected together 8 12 -3 51 Non-contiguous Disconnected, spread out 8 51 -3 12 Lesson 2 - Summer 2023 8

  9. Agenda References Review Linked Nodes Practice w/ ListNode Lesson 2 - Summer 2023 9

  10. sli.do code: #su_cse123 Linked Nodes Problem 1 Suppose we had the following ListNodes: data next data next data next list1 16 -3 27 data next data next list2 4 12 What happens when we execute: list1.next = list2.next? Lesson 2 - Summer 2023 10

  11. Linked Nodes Problem 2 What statements turn this picture: data next data next list1 10 20 data next data next list2 30 40 Into this picture? data next data next data next list1 10 20 30 data next list2 40 Lesson 2 - Summer 2023 Lesson 2 - Summer 2023 11

  12. Linked Nodes Problem 2 What statements turn this picture: data next data next list1 10 20 Answer: data next data next list1.next.next = list2; list2 = list2.next; list1.next.next.next = null; list2 30 40 Into this picture? data next data next data next list1 10 20 30 data next list2 40 Lesson 2 - Summer 2023 Lesson 2 - Summer 2023 12

  13. General Linked Nodes Steps 1. Determine what references need to change 2. Find which references are safe changes Set to null Redundant reference 3. Make safe changes 4. Repeat steps 2-3 until all references are updated Lesson 2 - Summer 2023 13

  14. Linked Nodes Problem 3 What statements turn this picture: data next data next data next list1 10 20 40 data next list2 30 Into this picture? data next data next list1 10 40 data next data next list2 Lesson 2 - Summer 2023 30 20 Lesson 2 - Summer 2023 14

  15. Linked Nodes Problem 3 What statements turn this picture: data next data next data next list1 10 20 40 data next list2 30 Into this picture? (1 Possible) Answer: data next data next list1 ListNode temp = list1.next; list1.next = list1.next.next; temp.next = list2; list2 = temp; 10 40 data next data next list2 Lesson 2 - Summer 2023 30 20 Lesson 2 - Summer 2023 15

  16. General Linked Nodes Steps 1. Determine what references need to change 2. Find which references are safe changes Set to null Redundant reference 3. Make safe changes If none exist, introduce temp variable 4. Repeat steps 2-3 until all references are updated Lesson 2 - Summer 2023 16

More Related Content