1 Traversing a List Iteration. Idiom for traversing a null-terminated linked list. for (Node x = first; x != null; x = x.next) { StdOut.println(x.item);

Presentation on theme: "1 Traversing a List Iteration. Idiom for traversing a null-terminated linked list. for (Node x = first; x != null; x = x.next) { StdOut.println(x.item);"— Presentation transcript:

1 Traversing a List Iteration. Idiom for traversing a null-terminated linked list. for (Node x = first; x != null; x = x.next) { StdOut.println(x.item); } AliceBobCarol null item next first

2 Traversing a List Iteration. Idiom for traversing a null-terminated linked list. for (Node x = first; x != null; x = x.next) { StdOut.println(x.item); } x AliceBobCarol null item next first

3 Traversing a List Iteration. Idiom for traversing a null-terminated linked list. for (Node x = first; x != null; x = x.next) { StdOut.println(x.item); } x AliceBobCarol null item next first

4 Traversing a List Iteration. Idiom for traversing a null-terminated linked list. Alice x for (Node x = first; x != null; x = x.next) { StdOut.println(x.item); } AliceBobCarol null item next first

5 Traversing a List Iteration. Idiom for traversing a null-terminated linked list. Alice for (Node x = first; x != null; x = x.next) { StdOut.println(x.item); } x AliceBobCarol null item next first

6 Traversing a List Iteration. Idiom for traversing a null-terminated linked list. Alice for (Node x = first; x != null; x = x.next) { StdOut.println(x.item); } x AliceBobCarol null item next first

7 Traversing a List Iteration. Idiom for traversing a null-terminated linked list. Alice Bob for (Node x = first; x != null; x = x.next) { StdOut.println(x.item); } x AliceBobCarol null item next first

8 Traversing a List Iteration. Idiom for traversing a null-terminated linked list. Alice Bob for (Node x = first; x != null; x = x.next) { StdOut.println(x.item); } x AliceBobCarol null item next first

9 Traversing a List Iteration. Idiom for traversing a null-terminated linked list. Alice Bob for (Node x = first; x != null; x = x.next) { StdOut.println(x.item); } x AliceBobCarol null item next first

10 Traversing a List Iteration. Idiom for traversing a null-terminated linked list. Alice Bob Carol for (Node x = first; x != null; x = x.next) { StdOut.println(x.item); } x AliceBobCarol null item next first

11 Traversing a List Iteration. Idiom for traversing a null-terminated linked list. Alice Bob Carol for (Node x = first; x != null; x = x.next) { StdOut.println(x.item); } x AliceBobCarol null item next first

12 Traversing a List Iteration. Idiom for traversing a null-terminated linked list. Alice Bob Carol for (Node x = first; x != null; x = x.next) { StdOut.println(x.item); } x AliceBobCarol null item next first

13 Traversing a List Iteration. Idiom for traversing a null-terminated linked list. Alice Bob Carol for (Node x = first; x != null; x = x.next) { StdOut.println(x.item); } AliceBobCarol null item next first

Download ppt "1 Traversing a List Iteration. Idiom for traversing a null-terminated linked list. for (Node x = first; x != null; x = x.next) { StdOut.println(x.item);"

Similar presentations