Section5-6Problems - CSE143 Section Enr t-haca n- r n f l g...

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: CSE143 Section Enr t-haca n- r n f l g 6 5 , rv aSSUme that we are *'6 P r o b l e m s F using the Standard LiStNOde CIaSS: public ListNode class t public int data; public ListNode next; public ListNode O this (0, nuII); ) i // // data Iink node stored in this to next node in the Iist public ListNode(int data) nuLl-) i t.his (data, ) public ListNode(int data, this . data data i : next; t.his.next ) i { ListNode next) { ,. Your task is to create a class called Linkedlntlist that has the same functionality as the Intlist class of handout #3 (minus the constructor that involves because linked Iists have no maximum capacity) capacity, In doing you have a single so, assume that data field of type ListNode front: called public Linkedlntlist class private ListNode front; <methods> ) r\ie wrote the appending add method in lecture: { public if woid add(int value) { (front nulI) f ront new ListNode (val-ue) ; else { ListNode front; current r: nuII) (current.next while current current.next; new ListNode (val-ue) ; current . next ) of the leqa.l-. fo]Iowi.ng methods. For those involving an index, ) r'le need each the index is a dssume zero-argument that constructor the current the number of elements given Iist. index in sguare brackets of in the list siz.e() returns that get(index) f n Q { -r ' i n n / \ the values ! lrrY \ / returns val-ue at the f hat returns in the Iist a comma-separated indexOf (walue) giwen value or add(index, returns that the -1 if not found that inserts the index of the first occurrence gj-ven of the value) that the value given at value the at the index index remove (index) removes qiven ...
View Full Document

Ask a homework question - tutors are online