130 likes | 241 Vues
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 ); }. first. Alice. Bob. Carol. null. item. next. Traversing a List.
E N D
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); } first Alice Bob Carol null item next
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 first Alice Bob Carol null item next
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 first Alice Bob Carol null item next
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 Alice first Alice Bob Carol null item next
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 Alice first Alice Bob Carol null item next
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 Alice first Alice Bob Carol null item next
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 Alice Bob first Alice Bob Carol null item next
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 Alice Bob first Alice Bob Carol null item next
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 Alice Bob first Alice Bob Carol null item next
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 Alice Bob Carol first Alice Bob Carol null item next
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 Alice Bob Carol first Alice Bob Carol null item next
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 Alice Bob Carol first Alice Bob Carol null item next
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); } Alice Bob Carol first Alice Bob Carol null item next