30.08.2014 Views

Arete Zafiriou - Student.cs.uwaterloo.ca

Arete Zafiriou - Student.cs.uwaterloo.ca

Arete Zafiriou - Student.cs.uwaterloo.ca

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

head – reference to the first node in the list<br />

tail – last node in the list<br />

link in the tail is a None reference<br />

Most nodes have no names or references.<br />

They are referenced by the link in the preceding node.<br />

Head – should be referenced by an external variable<br />

- entry point to the list<br />

- null head reference indi<strong>ca</strong>tes an empty list<br />

The Basic operations<br />

1. List traversal<br />

2. Search for an item<br />

3. Insert an item<br />

4. Delete an item<br />

…<br />

Traversing a List<br />

curNode <br />

<br />

9 17 52 4 <br />

We <strong>ca</strong>n traverse this list by creating a temporary reference<br />

curNode = head<br />

<br />

9 14 17 52 <br />

create a linked list<br />

LL = Node(9, Node(14,Node(17,Node(52,None))))<br />

N = Node(23)<br />

23 <br />

<br />

Traverse the list by advancing the temporary reference<br />

curNode = curNode._next<br />

Repeat again

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!