Code is as below
public DList clone(){
DList cloneList =new Dlist();
Node traverse = this.head;
while(traverse!=null){
cloneList.add(traverse.getData());
traverse = traverse.next;
}
return cloneList;
}
traverse points to first element of the current list to be cloned. while traverse does not equal null get the data of traverse and add it to the cloneList (assuming the function name is add, it could be append too). traverse point to next node in the list
this can be done separately.
int value = traverse.getData();
cloneList.add(value);
Consider the DList class provided in the Week 6 source code archive which stored int data. A common operation on a DList object list is to make a copy or clone of list. For example, DList list n...
8.9 Coding lab #5: create a dynamic array ADT and a singly linked list ADT. Honor Code Your answers to this homework must be your own work.You are not allowed to share your solutions.You may not engage in any other activities that will dishonestly improve your results or dishonestly improve or damage the results of others. Plagiarism Plagiarism is when you copy words, ideas, or any other materials from another source without giving credit. Plagiarism is unacceptable in any academic environment....