Traversing a List - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

Traversing a List

Description:

Carol. null. item. next. first. 2. Traversing a List. Iteration. ... Carol. for (Node x = first; x != null; x = x.next) { StdOut.println(x.item); Alice. Bob ... – PowerPoint PPT presentation

Number of Views:47
Avg rating:3.0/5.0
Slides: 14
Provided by: kevin59
Category:
Tags: carol | list | traversing

less

Transcript and Presenter's Notes

Title: Traversing a List


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
Write a Comment
User Comments (0)
About PowerShow.com