Please make sure the code works perfectly and is accurate. This is high-stake assignment. I will rate highly, thank you very much for saving my life.
Question:
Create a Java program that extends the LinkedList<E> class of java.util.* to ExtLinkedList<E> that would have these methods:
public class ExtLinkedList<E> extends LinkedList<E> {
public ExtLinkedList<E>subList() {
.... (stuff goes here)
}
}
which returns the values stored at index 0,3,6,9, … of the list. If given an empty list it should simply return the empty list. For example, subList() method for a non-empty list containing values {e0,e1,e2,e3, e4,e5,e6,e7} should return a list containing (e0, e3,e6}. The original list should not be modified. Your code should work for any size including the empty list and any parameter E. Also, the original LinkedList should remain intact and not have any of its contents removed. Estimate the run-time complexity of the method given the size of the original list is n.
No constructor is needed for the class ExtLinkedList<E> class.
Program:
import java.util.*;
//class ExtLinkedList
public class ExtLinkedList<E> extends
LinkedList<E>
{
//method to create the sublist
public ExtLinkedList<E>subList()
{
ExtLinkedList<E> sublist =
new ExtLinkedList<E>();
ListIterator<E> itr =
listIterator();
for(int i = 0; itr.hasNext(); i++)
{
E element = itr.next();
if(i % 3 == 0)
{
sublist.add(element);
}
}
return sublist;
}
}
//class Driver
class Driver
{
//main method
public static void main (String[] args)
{
//Create the linked list
ExtLinkedList<String> list =
new ExtLinkedList <String>();
//add the elements
list.addLast("e0");
list.addLast("e1");
list.addLast("e2");
list.addLast("e3");
list.addLast("e4");
list.addLast("e5");
list.addLast("e6");
list.addLast("e7");
Iterator itr = list.iterator();
//display the original
list
System.out.print("The original
LinkedList: ");
for(int i = 0; itr.hasNext(); i++)
{
System.out.print(itr.next() + " ");
}
System.out.println();
ExtLinkedList<String> sublist = list.subList();
itr = sublist.iterator();
//display the sublist
System.out.print("The sublist: ");
for(int i = 0; itr.hasNext(); i++)
{
System.out.print(itr.next() + " ");
}
}
}
Output:

The run-time complexity of the method given the size of the original list is n: O(n), since it needs to traverse and access each node of the original list .
N.B. Whether you face problem or you need help then share me in the comment section, I'll be happy to help you.
Please make sure the code works perfectly and is accurate. This is high-stake assignment. I will...
JAVA Write Java code for extending the LinkedList class of java.util.* to ExtLinkedList that would include the following method: public ExtLinkedList firstHalfList() which returns the first half of the list. In other words, if you have a ExtLinkedList of size 5, for example, the method firstHalfList should return the list with the first two nodes. If it is a list of size 6, it should return the list with the first three nodes. The original list should not be modified....
a Java code Complete the provided code by adding a method named sum() to the LinkedList class. The sum() method should calculate the sum of all of the positive numbers stored in the linked list. The input format is the number of items in the list, followed by each of the items, all separated by spaces. Construction of the linked list is provided in the template below. The output should print the sum of the positive values in the list....
Given a linked list of integers, write a method that computes and prints the pairwise sums which is illustrated below with an example. If the linked list has values 5,3,2,9,3,15,22 from head to tail, the pairwise sums would be 8,5,11,12,18,37 which is the sum of two consecutive values from left to right. Notice the output will be of size one less than the original. You will output the pairwise sums exactly as above on a single line, comma separated. If...
NO ONE HAS PROVIDED THE CORRECT CODE TO PROVIDE THE GIVEN OUTPUT. PLEASE PROVIDE CODE THAT WOULD CAUSE THE HW1.java TO PRINT THE RIGHT DATA.!!! The LinkedList class implements both the List interface and the Stack interface, but several methods (listed below) are missing bodies. Write the code so it works correctly. You should submit one file, LinkedList.java. Do not change the interfaces. Do not change the public method headers. Do not rename the LinkedList class. None of your methods...
PLEASE HELP! The assignment details are in the *noted part of the code. I REALLY need help. import java.util.LinkedList; public class TwoDTree { private TwoDTreeNode root; private int size; public TwoDTree() { clear(); } /** * Returns true if a point is already in the tree. * Returns false otherwise. * * The traversal remains the same. Start at the root, if the tree * is not empty, and compare the x-coordinates of the point passed * in and...
Doubly Linked List The assignment is to modify the below code in any way (like changing the method of a function). Time complexity is omitted. Any methods/functions below could be changed into something different. I was thinking of changing the method of getting size of list and maybe change from numbers to letters for nodes. import java.util.Scanner; /* Class Node */ class Node { protected int data; protected Node next, prev; /* Constructor */ public Node() { next = null;...
please help!!!! JAVA
I done the project expect one part but I still give you all the
detail that you needed...
and I will post my code please help me fix the
CreateGrid() part in main and make GUI works
List Type Data Structures
Overview :
You will be implementing my version of a linked list. This is a
linked list which has possible sublists descending from each node.
These sublists are used to group together all nodes which...
JUnit5 JAVA. Need help to make a unit test of my GenericStack.java code below. Feel free to change the code below to fit the task better. thanks :) Assigment Create a new version of GenericStack (Have started on the code below) that uses an array instead of an ArrayList (this version should also be generic). Be sure to check the size of the array before adding a new item; - if the array becomes full, double the size of the...
C++ LinkedList I need the code for copy constructor and assignment operator #include <iostream> #include <string> using namespace std; typedef string ItemType; struct Node { ItemType value; Node *next; }; class LinkedList { private: Node *head; // You may add whatever private data members or private member functions you want to this class. void printReverseRecursiveHelper(Node *temp) const; public: // default constructor LinkedList() : head(nullptr) { } // copy constructor LinkedList(const LinkedList& rhs); // Destroys all the dynamically allocated memory //...
Please use Java programming: Modify both ArrayList and LinkedList classes and add the following method to both classes: public void reverseThisList(), This method will reverse the lists. When testing the method: print out the original list, call the new method, then print out the list again ------------------------------------------------------------------------- //ARRAY LIST class: public class ArrayList<E> implements List<E> { /** Array of elements in this List. */ private E[] data; /** Number of elements currently in this List. */ private int size; /**...