
Concept explainers
1. Implement a List using array:
a. Implement ArrayList<T> class of ListADT<T> interface which will define the following
methods
(i) public T removeLast(); //Removes and returns the last element in the list.
(ii) public T removeFirst(); //Removes and returns the first element in the list.
(iii) public T remove(T element); //Removes and returns the specified element.
(iv) public boolean contains(T target); //Return True if the list contains the target
element otherwise False.
(v) public String toString(); // Returns a string representation of the list.
b. Implement ArrayUnorderedList<T> class which will extends ArrayList<T> by defining
the following additional methods
(i) public void addToFront(T element); //Adds the specified element to the front of
the list.
(ii) public void addToRear(T element); //Adds the specified element to the rear of the
list.
(iii) public void addAfter(T element, T target); //Adds the specified element after the
specified target element.
c. Create an object of ArrayUnorderedList<T> class and perform some add, remove, and
search operations and finally print the entire Stack.
2. Using Linked structure, implement LinkedList<T> class which will define the following
methods:
(i) public T removeLast(); //Removes and returns the last element in the list.
(ii) public T removeFirst(); //Removes and returns the first element in the list.
(iii) public T remove(T element); //Removes and returns the specified element.
(iv) public boolean contains(T target); //Return True if the list contains the target
element otherwise False.
a. Implement LinkedUnorderedList<T> class which will extends LinkedList<T> by defining the
following additional methods
(i) public void addToFront(T element); //Adds the specified element to the front of
the list.
(ii) public void addToRear(T element); //Adds the specified element to the rear of the
list.
(iii) public void addAfter(T element, T target); //Adds the specified element after the
specified target element.
b. Create an object of ArrayUnorderedList<T> class and perform some add, remove, and
search operations and finally print the entire list using iterator.
c. Create an object of LikedUnorderedList<T> class and perform the same set of add,
remove, and search operations of 2(b) and finally print the entire list using iterator. If
your array and linked based implementations are right, you should get the same result.

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

- Trace insertion sort for list ={18,57,8,89,7}arrow_forwardInstruction: To test the Linked List class, create a new Java class with the main method, generate Linked List using Integer and check whether all methods do what they’re supposed to do. A sample Java class with main method is provided below including output generated. If you encounter errors, note them and try to correct the codes. Post the changes in your code, if any. Additional Instruction: Linked List is a part of the Collection framework present in java.util package, however, to be able to check the complexity of Linked List operations, we can recode the data structure based on Java Documentation https://docs.oracle.com/javase/8/docs/api/java/util/LinkedList.html package com.linkedlist; public class linkedListTester { public static void main(String[] args) { ListI<Integer> list = new LinkedList<Integer>(); int n=10; for(int i=0;i<n;i++) { list.addFirst(i); } for(int…arrow_forwardGiven the interface of the Linked-List struct Node{ int data; Node* next = nullptr; }; class LinkedList{ private: Node* head; Node* tail; public: display_at(int pos) const; ... }; Write a definition for a method display_at. The method takes as a parameter integer that indicates the node's position which data you need to display. Example: list: 5 -> 8 -> 3 -> 10 display_at(1); // will display 5 display_at(4); // will display 10 void LinkedList::display_at(int pos) const{ // your code will go here }arrow_forward
- This is using Data Structures in Javaarrow_forwardJava programming language I have to create a remove method that removes the element at an index (ind) or space in an array and returns it. Thanks! I have to write the remove method in the code below. i attached the part where i need to write it. public class ourArrayList<T>{ private Node<T> Head = null; private Node<T> Tail = null; private int size = 0; //default constructor public ourArrayList() { Head = Tail = null; size = 0; } public int size() { return size; } public boolean isEmpty() { return (size == 0); } //implement the method add, that adds to the back of the list public void add(T e) { //HW TODO and TEST //create a node and assign e to the data of that node. Node<T> N = new Node<T>();//N.mData is null and N.next is null as well N.setsData(e); //chain the new node to the list //check if the list is empty, then deal with the special case if(this.isEmpty()) { //head and tail refer to N this.Head = this.Tail = N; size++; //return we are done.…arrow_forwardPROBLEM STATEMENT: Return a sublist of a given list from the range of the two integerinputs from, to. public class FindSublistFromRange{public static ArrayList<Integer> solution(ArrayList<Integer> elms, int from, int to){// ↓↓↓↓ your code goes here ↓↓↓↓return new ArrayList<>();} Can you help me with this question The language is Java Please use the code i provided above to answer this questionarrow_forward
- Given the following class declaration: class List { public: List(); List(const List&); List& operator=(const List&); -List(); // Inserts element in the specified position, returns true if // it was able to insert. // Example, if the list is [4, 2, 1], and the user // calls list.Insert(6, 1) the list would become [4, 6, 2, 1] bool Insert(double element, size_t position) ; // Returns the position of element if found, if not found returns -1 int Index0f(double element)const ; // Removes the element in the given position double Remove(size_t position) ; // Gets the number in the given position double Get(size_t position)const ; // Returns a string representation of the list, elements // separated by commas and the list between brackets string ToString()const ; // Returns the number of elements in the list size_t Size)const; // Returns true if the list is empty, false otherwise bool IsEmpty)const; // Clears the whole list void Clear(); private: struct Node{ double number; Node* next; };…arrow_forwardSend me your own work not AI generated response or plagiarised response. If I see these things, I'll give multiple downvotes and will definitely report.arrow_forwardIN JAVA PLEASE, need help finding an element in the list /** * Returns whether the given value exists in the list. * @param value - value to be searched. * @return true if specified value is present in the list, false otherwise. */ public int indexOf(int value) { //Implement this method return -1; }arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





