Question: In java I need help modifying the following sections: size, isEmpy, contains. I am trying to do this without changing any declaration of any method.

In java I need help modifying the following sections: size, isEmpy, contains. I am trying to do this without changing any declaration of any method. Thank you

public class MyST { private Node first;

private class Node { private Key key; private Value val; private Node next;

public Node(Key key, Value val, Node next) { this.key = key; this.val = val; this.next = next; } }

public MyST() { }

public int size() { return 0;\\ **** }

public boolean isEmpty() { return true; \\\*** }

public boolean contains(Key key) { if (key == null) throw new IllegalArgumentException("argument to contains() is null"); return false;\\\\ *** }

public Value get(Key key) { if (key == null) throw new IllegalArgumentException("argument to get() is null"); for (Node x = first; x != null; x = x.next) { if (key.equals(x.key)) return x.val; } return null; }

public void put(Key key, Value val) { if (key == null) throw new IllegalArgumentException("first argument to put() is null"); if (val == null) { delete(key); return; }

for (Node x = first; x != null; x = x.next) { if (key.equals(x.key)) { x.val = val; return; } } first = new Node(key, val, first); }

public void delete(Key key) { if (key == null) throw new IllegalArgumentException("argument to delete() is null"); first = delete(first, key); }

private Node delete(Node x, Key key) { if (x == null) return null; if (key.equals(x.key)) { return x.next; } x.next = delete(x.next, key); return x; }

public Iterable keys() { Queue queue = new Queue(); for (Node x = first; x != null; x = x.next) queue.enqueue(x.key); return queue; }

}

Current output:

In java I need help modifying the following sections: size, isEmpy, contains.

Correct output:

I am trying to do this without changing any declaration of any

X 7 E 12 st dae et dae at doe dae et does at dae da- et doe st dae et doe ain

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!