Section5-6Key 2 - appends the given value to the end of...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: appends the given value to the end of / / post: public woid add(int value) { (front if null) front new ListNode (value) ; el-se t ListNode current front; r: nul-I) (current. next while : current.next; current new ListNode (value) ; current, next ) l the list 0 <: index / / pre: inserts the given val-ue at the given index // post: public void add (int index, int val-ue) { (index := 0) if front new ListNode (value, front); i' else { ListNode current front; (int for i : 0; i < index L; i++1 current current. next; current . next new ListNode (value, current . next ) ; ) ) : 0 (= index < size o / / pre removes val-ue at the given / / post: index public woid remowe (int index) { (index :: if 0) front front. nexti el_se { List.Node current f ront; (int for i : 0; i < index I; i++1 current current.. next; current . next current . next . next; ) ) ...
View Full Document

This note was uploaded on 11/03/2009 for the course CSE 143 taught by Professor Sr during the Spring '08 term at University of Washington.

Ask a homework question - tutors are online