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

Overall description of the project, that includes a brief description of the Lis

ID: 3812348 • Letter: O

Question

Overall description of the project, that includes a brief description of the List ADT. please put in paragraph form

what to do for the project

Design, implement and test a List ADT implementation based on a doubly linked list that uses the authors' DLLNode object (found in the support folder). In addition to the authors' standard list operations , your class must support backward iteration through the list via resetBack and getPrevious methods. The authors suggest including an instance variable that always references the last element on the list. Consider the remove operation for a doubly linked list and design and create the code for remove. Remember to handle all of the special cases.

DLLNode.JAVA

package ddladt;

public class DLLNode<T>

{

private DLLNode<T> next,back;

private T info;

public DLLNode(T info)

{

this.info = info;

next = null;

}

public void setInfo(T info)

{

this.info = info;

}

public T getInfo()

{

return info;

}

public void setNext(DLLNode<T> next)

{

this.next = next;

}

public DLLNode<T> returnNext()

// Returns next link of this DLLNode.

{

return next;

}

public void setBack(DLLNode<T> back)

{

this.back = back;

}

public DLLNode<T> getBack()

{

return back;

}

}

DLLAdt.JAVA

package ddladt;

public class DLLAdt<T>

{

protected int elemNum;

protected DLLNode<T> current;

protected DLLNode<T> backCurrent;

protected boolean status;

protected DLLNode<T> pos;

protected DLLNode<T> backe;

protected DLLNode<T> dlList;

protected DLLNode<T> end;

//class constructor

public DLLAdt()

{

elemNum = 0;

dlList = null;

end = null;

current = null;

backCurrent = null;

}

//to insert to dd list

public void add(T element)

{

DLLNode<T> newNode = new DLLNode<T>(element);

if(dlList==null)

{

dlList = newNode;

end = dlList;

}

else

{

dlList.setBack(newNode);

newNode.setNext(dlList);

dlList = newNode;

}

elemNum++;

}

protected void find(T target)

{

pos = dlList;

status = false;

while (pos != null)

{

if (pos.getInfo().equals(target))

{

status = true;

return;

}

else

{

backe = pos;

pos = pos.returnNext();

}

}

}

//to get the size

public int size()

{

return elemNum;

}

//to check the presence of an entry

public boolean contains (T element)

{

find(element);

return status;

}

//to delete entries from the list

public boolean delete (T element)

{

find(element);

if (status)

{

if (dlList == pos)  

dlList = dlList.returnNext();

else

backe.setNext(pos.returnNext());

elemNum--;

}

return status;

}

public T get(T element)

{

find(element);

if (status)

return pos.getInfo();

else

return null;

}

public String toString()

{

DLLNode<T> currNode = dlList;

String listString = "List: ";

while (currNode != null)

{

listString = listString + " " + currNode.getInfo() + " ";

currNode = currNode.returnNext();

}

return listString;

}

//reset teh list

public void reset()

{

current = dlList;

}

public void backReset()

{

backCurrent = end;

}

public T returnNext()

{

T next = current.getInfo();

if (current.returnNext() == null)

current = dlList;

else

current = current.returnNext();

return next;

}

//get previous

public T getPrevious()

{

T pre = backCurrent.getInfo();

if (backCurrent.getBack() == dlList)

backCurrent = end;

else

backCurrent = backCurrent.getBack();

return pre;

}

}

Test.JAVA

package ddladt;

//The driver program

public class Test

{

public static void main(String args[])

{

DLLAdt<Integer> dlList= new DLLAdt<Integer>();

for(int itr=100;itr>1;itr-=10)

    dlList.add(itr);

System.out.println(dlList.toString());

dlList.reset();

dlList.backReset();

System.out.println(" Testing the returnNext() function");

System.out.print(" "+dlList.returnNext().intValue());

System.out.print(" "+dlList.returnNext().intValue());

System.out.print(" "+dlList.returnNext().intValue());

System.out.println(" Testing the getPrevious() function");

System.out.print(" "+dlList.getPrevious().intValue());

System.out.print(" "+dlList.getPrevious().intValue());

System.out.print(" "+dlList.getPrevious().intValue());

}

}

Explanation / Answer

Here is a descrption of the DLLAdt class.

This project involves the implementation of n Abstract Data Type for Doubly Linked List. The linked list uses a Node class to store each item in the list. The Node class consists of the item to store, a link to the nest node and a link to the previous node. The double linked list implementation allows for various functionalities such as deleting a node, adding new nodes, reset the previous node, check whether a node is present in the list or not.

List ADT:

The JAVA List Abstract Data Type allows to maintain a list of items. This is an Interface and it allows for various operations such as checking whether a list is empty, returning the size of the list, checking whether the list contains a particular element. This interface can be implemented through custom classes of our own or we can use JAVA provided List ADT implemented classe such as ArrayList.