Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java (Linked List Assignment) /* * CSCHomework6 version 1.0 * * this class maintains a linked structure via the instance variable first * As an

Java (Linked List Assignment)

/* * CSCHomework6 version 1.0 * * this class maintains a linked structure via the instance variable first * As an abstract data type, you should think of this class as a linked list * * Complete the method below marked ToDo * None of the methods should modify the list, unless that is the express purpose of the method. * * You may not add any instance variables to the node or list classes. * You may not add any methods to the node class. * * You may not use the toString method to solve any of the toDos * You may use the toString method for debugging - e.g. to print the list contents * * You may add private methods to the CSCHomework6 class (helper functions for the recursion). * * You may NOT use arrays or other Java classes without permission. */

static class Node { public Node (char item, Node next) { this.item = item; this.next = next; } public char item; public Node next; }

Node first; // this is the only instance variable, // the access point to the list //This is the problem to solve. Solve maxCharacter recursively using a linked list. /* * maxCharacter * * a function to compute the 'maximum' character in the list using recursion * You will want to create a helper function to * do the recursion * * precondition: list is not empty * * Examples: * ["ababcdefb"].maxCharacter() == 'f' * ["eezzg"].maxCharacter() == 'z' * ["a"].maxCharacter() == 'a' */ public char maxCharacter () { return '*'; //TODO 1: fix this }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions