Section6Key 2 - One possible so.l-ution appears below publ...

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: One possible so.l-ution appears below. publ i c int numDuplicates Ot i nlcount 0; (front if !: null) { ListNode current front; whiLe (current . next ! : nu-l1) i (current.data if :: current. count++; : current . next current r. ) ) ra1- u r n count; ) One possible public if soluti-on appears be1ow. next.data) ilt maxAdjacentpairSum ( ) { (front :: nuII | | f ront.nexl - :: nrrt .l "e.r/ \ return o; el-se { ListNode : front; current int max front.data + front. next. data; whi l-e (current . next ! : n u l _l _) { int next current . data + current.next.data; (next > max) if max : next; current current. next; t return ) One possibLe solution max; appears bel-ow. pubJ.ic void stutter O{ ListNode current front; while (current !_ null) { current . next new ListNode (current current current . next . next; I I . data, current. next) ; One possible pubtic if solution appears below. void sptit O {_ (front !: null) { ListNode current front; whiJ-e (current. next !- nuII) { (current . next . data < O) if { ListNode temp current . next; current. next current. next . next; temp.next : front; : temp; front ) eLse : current.next; current ) ...
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