1 / 13

Traversing a List

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.

Download Presentation

Traversing a List

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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); } first Alice Bob Carol null item next

  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 first Alice Bob Carol null item next

  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 first Alice Bob Carol null item next

  4. 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

  5. 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

  6. 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

  7. 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

  8. 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

  9. 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

  10. 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

  11. 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

  12. 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

  13. 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

More Related