10-linked_list - CSE143 Lecture10 LinkedListBasics...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 143 Lecture 10 Linked List Basics reading: 16.1 - 16.2 slides created by Marty Stepp http://www.cs.washington.edu/143/
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 References vs. objects variable = value ; variable   (left side of  =  )  is an arrow    (the base of an arrow) 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
Background image of page 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 30 b data next 40
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Linked node question Suppose we have a long chain of list nodes: We don't know exactly how long the chain is. How would we print the data values in all the nodes? data next 10 data next 990 list ... data next 20
Background image of page 4
5 Algorithm pseudocode Start at the  front  of the list. While (there are more nodes to print): Print the current node's  data . Go to the  next  node. How do we walk through the nodes of the list? list = list.next; // is this a good idea?
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/04/2011 for the course CSE 143 taught by Professor Sr during the Spring '08 term at University of Washington.

Page1 / 21

10-linked_list - CSE143 Lecture10 LinkedListBasics...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online