Thursday, October 6, 2011


function addToFront(value x): #DLinked List, no 'header'
n = new Node(x)
n.next = head
n.prev = null

head.prev = n
head = n
size++
#actually, have to test for 0 elements to set tail

function addToFront(value x): #DLinked List, with 'header'
n = new Node(x)
n.prev = header
n.next = header.next
header.next = n
n.next.prev = n
size++

HW:
templatize your stack class

No comments:

Post a Comment