Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Add stubbed versions of all of the methods required by the List interface and im

ID: 3852949 • Letter: A

Question

Add stubbed versions of all of the methods required by the List interface and implement the add method to add an element to the end of the list. You will find it useful to download or copy the code from the LinkedNode class in the course Github repository.

not on java but just by words, describe the best, average, and worst case time complexity of the method using Big O notation. What would the complexity be without a tail?

>> copying code

public class LAB13 {

public interface List<T> {

void add(T element);

void insert(int index, T element);

T remove(int index);

T get(int index);

int size();

}

public class LinkedList<E> implements List<E> {

private LinkedNode<E> head;

private LinkedNode<E> tail;

private int size;

public LinkedList() {

head = null;

tail = null;

size = 0;

}

@Override

public void add(E element) {

// TODO Auto-generated method stub

}

@Override

public void insert(int index, E element) {

// TODO Auto-generated method stub

}

@Override

public E remove(int index) {

// TODO Auto-generated method stub

return null;

}

@Override

public E get(int index) {

// TODO Auto-generated method stub

return null;

}//

@Override

public int size() {

// TODO Auto-generated method stub

return 0;

}

}

public class LinkedNode<E> {

private E data;

private LinkedNode<E> next;

public LinkedNode(E data) {

this(data, null);

}

public LinkedNode(E data, LinkedNode<E> next) {

this.data = data;

this.next = next;

}

public E getData() {

return data;

}

public void setData(E data) {

this.data = data;

}

public LinkedNode<E> getNext() {

return next;

}

public void setNext(LinkedNode<E> next) {

this.next = next;

}

}

}

public class LAB13 public interface List { void add(T element); void insert(int index, T element); T remove(int index); T get(int index); int size(); public class LinkedList

Explanation / Answer

public class LAB13 {

public interface List<T> {

void add(T element);

void insert(int index, T element);

T remove(int index);

T get(int index);

int size();

}

public class LinkedList<E> implements List<E> {

private LinkedNode<E> head;

private LinkedNode<E> tail;

private int size;

public LinkedList() {

head = null;

tail = null;

size = 0;

}

@Override

public void add(E element) {

// TODO Auto-generated method stub

}

@Override

public void insert(int index, E element) {

// TODO Auto-generated method stub

}

@Override

public E remove(int index) {

// TODO Auto-generated method stub

return null;

}

@Override

public E get(int index) {

// TODO Auto-generated method stub

return null;

}//

@Override

public int size() {

// TODO Auto-generated method stub

return 0;

}

}

public class LinkedNode<E> {

private E data;

private LinkedNode<E> next;

public LinkedNode(E data) {

this(data, null);

}

public LinkedNode(E data, LinkedNode<E> next) {

this.data = data;

this.next = next;

}

public E getData() {

return data;

}

public void setData(E data) {

this.data = data;

}

public LinkedNode<E> getNext() {

return next;

}

public void setNext(LinkedNode<E> next) {

this.next = next;

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote