Question: Java - Only answer this if you understand it. I have already asked this only to get useless answers and no help so please ask

Java - Only answer this if you understand it. I have already asked this only to get useless answers and no help so please ask questions. It is only a linked list -- not anything more advanced than that, there are no hash, no arrays, etc. Please only code for a linked list.

Java - Only answer this if you understand it. I have already

~ This would be for testing purposes ~

public String toString () { StringBuilder result = new StringBuilder (""); for (Node x = first; x != null; x = x.next) result.append ( x.item); return result.toString (); } public static Program of(String s) { Node first = null;

for (int i=s.length()-1; i >=0; i--) first = new Node (s.charAt(i), first);

Program result = new Program (); result.first = first; return result; }

private static void testNumUnique (int expected, String sList) { Program list = Program.of (sList); String sStart = list.toString (); int actual = list.numUnique(); boolean status = true; if (expected != actual) { StdOut.format ("Failed [\"%s\"].numUnique(): Expecting: %d Actual: %d ", sStart, expected, actual); status = false; } String sEnd = list.toString (); if (! sStart.equals (sEnd)) { StdOut.format ("Failed [\"%s\"].numUnique(): List changed to %s ", sStart, sEnd); status = false; } if ( status && showMeSuccess) StdOut.format ("Success numUnique(): Result: %d input: %s ", actual, sStart); }

* numUnique returns the number of unique values the list * Precondition: the list is not empty and is sorted from low to high. { your solution can assume this is true } * For full credit, your solution must go through the list exactly once. Your solution may not call any other functions. == 6 Examples: 1 ["abcdef"]: numUnique() ["aaabcd"). numUnique ['bccddee"). numUnique() ["abcddd"). numUnique ["a"l.numUnique() ==

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!