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

Java - data structure The file UnsortedLinkedDictionary.java contains unimplemen

ID: 3819685 • Letter: J

Question

Java - data structure

The file UnsortedLinkedDictionary.java contains unimplemented methods for a dictionary based on an unsorted linked list. Implement all these methods.

import java.util.Iterator;
import java.util.NoSuchElementException;

public class UnsortedLinkedDictionary<K, V> {
  
   public UnsortedLinkedDictionary() {

   } // end default constructor
  
public V add(K key, V value) {

} // end add

public V remove(K key) {
   
} // end remove

public V getValue(K key) {
  
} // end getValue

   public boolean contains(K key) {

} // end contains

public boolean isEmpty() {
  
} // end isEmpty
  
public int getSize() {
  
} // end getSize

   public final void clear() {
  
   } // end clear

   public Iterator<K> getKeyIterator() {
  
   } // end getKeyIterator
  
   public Iterator<V> getValueIterator() {
      
   } // end getValueIterator

   private class Node {
       private K key;
       private V value;
       private Node next;

       private Node(K searchKey, V dataValue) {
           key = searchKey;
           value = dataValue;
           next = null;  
       } // end constructor
      
       private Node(K searchKey, V dataValue, Node nextNode) {
           key = searchKey;
           value = dataValue;
           next = nextNode;  
       } // end constructor
      
       private K getKey() {
           return key;
       } // end getKey
      
       private V getValue() {
           return value;
       } // end getValue

       private void setValue(V newValue) {
           value = newValue;
       } // end setValue

       private Node getNextNode()
       {
           return next;
       } // end getNextNode
      
       private void setNextNode(Node nextNode) {
           next = nextNode;
       } // end setNextNode
   } // end Node
} // end UnsortedLinkedDictionary
      

Explanation / Answer

import java.util.Iterator;
import java.util.NoSuchElementException;

public class UnsortedLinkedDictionary<K, V> {
  
   public UnsortedLinkedDictionary() {

   } // end default constructor
  
public V add(K key, V value) {

} // end add

public V remove(K key) {
   
} // end remove

public V getValue(K key) {
  
} // end getValue

   public boolean contains(K key) {

} // end contains

public boolean isEmpty() {
  
} // end isEmpty
  
public int getSize() {
  
} // end getSize

   public final void clear() {
  
   } // end clear

   public Iterator<K> getKeyIterator() {
  
   } // end getKeyIterator
  
   public Iterator<V> getValueIterator() {
      
   } // end getValueIterator

   private class Node {
       private K key;
       private V value;
       private Node next;

       private Node(K searchKey, V dataValue) {
           key = searchKey;
           value = dataValue;
           next = null;  
       } // end constructor
      
       private Node(K searchKey, V dataValue, Node nextNode) {
           key = searchKey;
           value = dataValue;
           next = nextNode;  
       } // end constructor
      
       private K getKey() {
           return key;
       } // end getKey
      
       private V getValue() {
           return value;
       } // end getValue

       private void setValue(V newValue) {
           value = newValue;
       } // end setValue

       private Node getNextNode()
       {
           return next;
       } // end getNextNode
      
       private void setNextNode(Node nextNode) {
           next = nextNode;
       } // end setNextNode
   } // end Node
} // end UnsortedLinkedDictionary
      

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote