Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

LinkedListBox Patterned after the ArrayBox assignment, please create your own implementation of LinkedList called LinkedListBox as explained in class. Refer to the class slides on

LinkedListBox

Patterned after the ArrayBox assignment, please create your own implementation of LinkedList called LinkedListBox as explained in class. Refer to the class slides on linked lists. Specifically, implement your generic classes as:

public class LinkedListNode { public E element; public LinkedListNode next; } public class LinkedListBox { public LinkedListNode head; public LinkedListNode tail; public int count = 0; }

Within the LinkedListBox class, implement the following methods:

public boolean add(E e). Returns true after adding an element to the end of the list.

public E get(int idx). Returns element at index position idx.

public E set(int idx, E e). Changes the element at position idx to e. Returns old element.

public E remove(int idx). Removes element at position idx from the list and returns it.

public int size(). Self-explanatory

public boolean isEmpty(). Self-explanatory

public Integer find(E e). Search for element e in the linked list and return its index position or return null if not found.

public E removeFirst(). Remove and return the element at the head of the list.

public E removeLast(). Remove and return the element at the tail of the list.

public void addFirst(E e). Add an element to the front of the list.

public void insert(int idx, E e). Insert an element right after the index idx position.

Create a driver class called LinkedListBoxDriver. Provide the user a menu:

=[==[==[=[=================================]=]==]==]= =[==[==[=[ Welcome to LinkBox ]=]==]==]= =[==[==[=[=================================]=]==]==]= Choose... 1. Add an element(String) to our box. 2. Remove an element(String) from our box. 3. Replace(set) an element(String) from our box. 4. Insert an element(String) after index. 5. List the contents of the box. 6. Exit program

in java

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

Students also viewed these Databases questions