Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class MyLinkedList implements Iterable { private int theSize; private Node beginMarker; private Node endMarker; public class Node { public Node (AnyType data, Node head,

public class MyLinkedList implements Iterable { private int theSize; private Node beginMarker; private Node endMarker; public class Node{ public Node (AnyType data, Node head, Node tail){ myData=data; myHead=head; myTail=tail; } public AnyType myData; public Node myHead; public Node myTail; } public MyLinkedList(){} public void clear(){} public int size(){ } public boolean exist(AnyType newVal){ } public boolean add(AnyType newVal){ } public boolean add(int index, AnyType newVal) { } public Node get(AnyType nodeData){} public void printList(){}; public java.util.Iterator iterator(){} public void remove(AnyType removeVal){} private class LinkedListIterator implements java.util.Iterator{ public void remove(){} public boolean hasNext() {} public AnyType next() {} } private void addBefore(Node previousNode, AnyType newNode){} private void testListIntegers(){ MyLinkedList testList = new MyLinkedList(); testList.add(new Integer(5)); testList.add(new Integer(4)); testList.add(new Integer(3)); System.out.println(" We have so far inserted " + testList.size() + " elements in the list"); testList.remove(4); System.out.println(" Now, there is only " + testList.size() + " elements left in the list"); testList.add(1, new Integer(7)); testList.add(2, new Integer(8)); System.out.println(" About to print content of the list"); testList.printList(); } private void testListStrings(){ MyLinkedList testList = new MyLinkedList(); testList.add(new String("hello")); testList.add(new String("this is")); testList.add(new String("cs3345 project 2")); System.out.println(" We have so far inserted " + testList.size() + '' elements in the list"); testList.remove("this is"); System.out.println(" Now, there is only " + testList.size() + " elements left in the list"); testList.add(1, "a modified version of"); testList.add(2, "cs3345 project 2, call it version 2" ); System.out.println(" About to print content of the list"); testList.printList(); } public static void main (String args[]) throws Exception { // Add whatever code you need here // However, you will need to call both testListIntegers() // and testListStrings() } }

Finish the coding the following double-linked list implementation (called myLinkedList) given bellow:

Most of the functions/definitions are not finished. You should code the existing functions without changing their existing definition. Also, you can add code to the main function. The goal is to show that you have a complete myLinkedList implementation. If needed, add new functions/methods to complete your implementation. Hint: Some of the definitions are already in the textbook, but might be a bit different

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

What is Constitution, Political System and Public Policy? In India

Answered: 1 week ago

Question

What is Environment and Ecology? Explain with examples

Answered: 1 week ago

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago