Question
In this project, write 4 java class:: an array-based ordered list, a linked list-based ordered list, a linked list-based unordered list, a Node class for
In this project, write 4 java class:: an array-based ordered list, a linked list-based ordered list, a linked list-based unordered list, a Node class for the two linked lists. A user program is provided that tests these classes. This user program searches the array, and deletes every 5th item. It also keeps track of the number of operations used(searching, inserting, and deleting).
Here are items that need to be included in the 3 list classes:
void insert(int value): perform an insert of a new value into the list for the array-based list, or a new Node containing the value for the linked list types; insert at the appropriate position if its an ordered list; insert at the beginning for the unordered list
(int or Node) search(int value): for the linked list types, return the Node containing the value or null if the value is not found; for the array-based list type, return the position at which it was found or -1 if the value is not found. For the ordered array based list use binary search.
void delete(int value): locate and remove an item from the list; shift the elements to maintain a contiguous list
int getCount(): return the number of operations (count) in total to do inserts, deletes, and searches.
import java.util.*; import java.io.*; public class ListUser { public static void main(String[] args) throws IOException { Scanner in=new Scanner(new File("input1.txt")); int size=in.nextInt(); int i; int[] array=new int[size]; for(i=0;i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started