Question: import java.util.Iterator; public class customDSLL implements Iterable { private Node front; private Node back; private class Node{ /* * TO DO * Inner class */
import java.util.Iterator;
public class customDSLL
private Node front;
private Node back;
private class Node{
/*
* TO DO
* Inner class
*/
}
public boolean isEmpty() {
/*
* TO DO
* return true if the DS is empty, else return false
*/
return true;
}
public int size() {
/*
* TO DO
* return the size of the DS, i.e the number of elements in the DS. Can you do it in constant time?
*/
return 0;
}
public void insertFront(Item it) {
/*
* TO DO
* Insert a new element at the front pointer.
*/
}
public void insertBack(Item it) {
/*
* TO DO
* Insert a new element at the back pointer.
*/
}
public Item removeFront() {
/*
* TO DO
* Remove a new element from the front pointer.
*/
return null;
}
public Item removeBack() {
/*
* TO DO
* Remove a new element from the back pointer.
*/
return null;
}
public Iterator
/*
* TO DO
* Implement the iterator to enable usage of "foreach" loop.
*/
return null;
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
