This preview shows page 1. Sign up to view the full content.
Unformatted text preview: CSE143 Section For Lhese public
^..h1 #6 Problems using the standard ListNode class: problems, class
..1 ^ assume that (
next, we are ListNode
;  .^..t data; ListNode r,uvrlu public // // daLa link in this node stored node in the to next list public ListNode O this (0, null); ) t public ListNode (int data) nuII); this (data, ) public ListNode this . data this . next i ) (int data, data i next; { ListNode next) i "' we are writing methods for a class called And that front: data field of type ListNode called single public class LinkedlntList private ListNode front; <methods> ) In 1. solving these problems, you may not call any { Linkedlntlist that has a other methods of of the class. If Write a method min is empty, the list returns that the minimum value in a List it should throw an IllegalStateException. inteqers. 2. whether or not a list returns Write a method hasTwoConsecutive that of (returning numbers that integers has two adjacent are consecutive integers For example, if exists and returning faLse otherwise) . if such a pair true the following sequence of values: stores a varjable calIed list , then the Iist 18, caLl: . hasTwoConsecutive () list contains numbers. lf 40, the adjacent instead the numbers (1, B) list had stored 2,'7, 8, 39, 18, 40] true because the shouLd return which are a pair of consecutive sequence of values: this [1, 18, I7, 2, J, 39, 18, B] return faLse. This sequence contaj.ns some pairs then the method should of (e.9., numbers that could represent integers 1 and 2, ? and 8, consecutive 39 and 4Or, but those pairs of numbers are not adjacent in the sequence. of adjacent The list also has a pair numbers (18, I1) that are not in the riahr nrrror to be considered q consecutlve: Yog mqL_no! *rlrg}g_ ny aqs_q$p!i_oqs __ about how manv elements aie in the f :st. 3. Write that returns a method isSorted true if (nondecreasing) and that returns false order considered to be sorted. the list is otherwise. in sorted An empty list is ...
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.
 Spring '08
 SR

Click to edit the document details