This preview shows pages 1–4. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 CSE 143 Lecture 6 Linked List Basics slides created by Marty Stepp and Ethan Apter http://www.cs.washington.edu/143/ 2 References vs. objects variable = value ; a variable (left side of = ) is an arrow (the base of an arrow) a value (right side of = ) is an object (a box; what an arrow points at) • For the list at right: – a.next = value ; means to adjust where points – variable = a.next; means to make variable point at data next 10 a data next 20 1 2 1 2 2 3 Reassigning references • when you say: – a.next = b.next; • you are saying: – "Make the variable a.next refer to the same value as b.next ." – Or, "Make a.next point to the same place that b.next points." data next 10 a data next 20 data next 30 b data next 40 4 Basic Linked List Questions • Suppose you have two variables of type ListNode named p and q . Consider the following situation: data next data next p 2 4 data next data next q 3 9 • How many variables of type ListNode are there? • How many ListNode objects are there? 2 3 Reassigning references • when you say: – a.next = b.next; • you are saying: – "Make the variable a.next refer to the same value as b.next ." – Or, "Make a.next point to the same place that b.next points." data next 10 a data next 20 data next 30 b data next 40 4 Basic Linked List Questions • Suppose you have two variables of type ListNode named p and q . Consider the following situation: data next data next p 2 4 data next data next q 3 9 • How many variables of type ListNode are there? • How many ListNode objects are there? 3 5 Basic Linked List Questions • How many variables of type ListNode are there? – 6, circled in green data next data next p 2 4 data next data next q 3 9 6 Basic Linked List Questions • How many ListNode objects are there?...
View Full Document

{[ snackBarMessage ]}