Question: This is a basic Linked list in JAVA. Please it has classes for Linked list and nodes, and Constructor. Also we have to throw an

This is a basic Linked list in JAVA. Please it has classes for Linked list and nodes, and Constructor. Also we have to throw an error , as the * comment says, please have a commented well written code to be presentable . Thanks

Required package name: assign4 Required class name: OrderedLinkedList File to submit: OrderedLinkedList.java

OrderedLinkedList

- list: node

- count: int

- + OrderedLinkedList()

+ numEntries(): int + insert (int): void + delete (int): void * + toString(): String + get(int): int *

* Throws exception Required methods

1. OrderedList () a. create an empty linked list of integers

2. numEntries():int

a.

insert a. b.

delete a.

b.

return the values in the array so that all values are separated by a space

the string should be 1 2 3 not 1 2 3

an empty list should return an empty string (0 characters)

6. get(int): int

find the integer in the list at the position indicated and return it

if the value is not in the list, throw an exception with the string containing the number of

the position and the message Get not successful

the position of the nodes starts at 0, not 1

return the number of integers currently stored in the list (int): void

insert an integer into the list so that the elements are in ascending order

do not allow for duplicates in the array (int): void

find the integer in the list and remove it if the value is not in the array, throw an exception with the string containing the number that could not be deleted and the message Delete not successful if the value is in the array, remove it so that the elements remain in ascending order

c. 5. toString(): String

Implementation requirements:

You must use singly linked list of integers as given below. You may not use a Java Collection or other data structures.

public class OrderedLinkedList { private class IntNode {

public int info; public IntNode next;

IntNode (int num, IntNode ptr) { info = num;

next = ptr; }

}

private IntNode list;

private int count; }

The toString() and get(int) methods must be implemented using recursion. You may add other private methods as needed to accomplish this.

Follow all style and documentation requirements for the class.

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!