Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please create a a sparseVector.java class you are given public class Node { private Node next ; private int index ; private double value ;
please create a a sparseVector.java class
you are given
public class Node { private Node next; private int index; private double value; public Node(int idx, double val){ index = idx; value = val; next = null; } public double getValue(){return value;} public int getIndex(){return index;} public Node getNext(){return next;} public void setNext(Node other){next = other;} public String toString(){return ""+value; } }
Removing a Node Implement the following method: public void removeElement(int index) As its name suggests, this method should remove a node at the specified index from the sparse vector. Be sure to properly update the linked list and handle special cases (e.g., empty list, bad index, etc...). Test your method with the following code SparseVector x = new SparseVector (100000000); x.addElement(0, 1.0); x.addElement(10000000, 3.0); 4 CSCI 1933 LAB 7 4. REMOVING A NODE x.addElement(10000001, -2.0); SparseVector y = new Sparse Vector (100000000); y.addElement(0, 2.0); y.addElement(10000001, -4.0); y.removeElement(0); double result = dot(x, y); System.out.println(result); What should the result be? Milestone 4: Implement SparseVector::removeElement and show your TA the result of using the code above. Try removing other elements, both ones that exist in the sparse vector and ones that do not, and show what happens
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started