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.

1) NewNode._next = curNode._next<br />

curNode._next = newNode<br />

Insert at the end of the list as an exercise.<br />

Removing an item from SLL<br />

Search for the item that we want to remove<br />

remove(17) predNode._next = curNode.next<br />

curNode._next = None<br />

9 14 17 52 <br />

<br />

<br />

head predNode curNode <br />

deleting the head of the SLL<br />

9 14 17 52 <br />

<br />

preNode <br />

head <br />

curNode <br />

head = head._next<br />

curNode._next = None<br />

We need to update the head in this <strong>ca</strong>se<br />

ADT sequence<br />

Data: linear collection of items<br />

Operations:<br />

Sequence()<br />

__repr__<br />

__getItem__<br />

len<br />

append<br />

insert<br />

extend<br />

pop<br />

remove<br />

reverse<br />

Implement this ADT using SLL

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

Saved successfully!

Ooh no, something went wrong!