Implement the get(int index) method. on to this code.. not on java but just by w
ID: 3852950 • Letter: I
Question
Implement the get(int index) method. on to this code.. not on java but just by word describe the best, average, and worst case time complexity of the method using Big O notation
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 LinkedListExplanation / 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;
}
}
}