Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

package hw6; import java.util.NoSuchElementException; public class MyList { private class MyListNode { public Item item; public MyListNode next; public MyListNode(Item i, MyListNode n) { item

package hw6;

import java.util.NoSuchElementException;

public class MyList { private class MyListNode { public Item item; public MyListNode next; public MyListNode(Item i, MyListNode n) { item = i; next = n; } } private MyListNode first; /** * Creates an empty list. */ public MyList() { first = null; } /** * Inserts an item at the front of the list * * @param item the item to be inserted */ public void insertAtFront(Item item) { MyListNode node = new MyListNode(item, first); first = node; } /** * Returns the number of items equal to {@code target} in the list * * @param target the data item to count * @return the number of times {@code target} appears in the list */ public int count(Item target) { // TODO return -1; }

/** * Returns the data in position {@code index} in the list. * Note that like arrays the first data item is in position 0. * @param index the index of the item to get from the list * @throws NoSuchElementException if the list doesn't have a * position {@code index} * @return the data in position {@code index} in the list. */ public Item get(int index) { // TODO return null; }

/** * Constructs a separate copy of a list. Changes to the copy do not affect the original. * @return a copy of the list */ public MyList copy() { // TODO return null; }

/** * Constructs a {@code String} representation of the list. The {@code String} * is a comma separated listing of the {@code String} representations of the items * in the same order they appear in the list. There are no spaces between items. * @return a {@code String} representation of the list. */ public String convertToString() { // TODO return null; } /** * Deletes the first occurrence of {@code target} from the list if it is present. * Does nothing if {@code target} is not present. * * @param target the item to be deleted */ public void delete(Item target) { //TODO } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions

Question

customers

Answered: 1 week ago

Question

b. Where did they come from?

Answered: 1 week ago