Question: In java plz, will give 5 stars! We are going to implement a Java class for big integers using singly linked list. The main idea
In java plz, will give 5 stars!
We are going to implement a Java class for big integers using singly linked list. The main idea of the data representation is illustrated by the following figure.

The above singly linked list represents the number -24 1576 3190, such that the head node keeps the sign, and the rest of the nodes keeps the digits in a reverse order. That is, the 2nd node keeps the last 4 digits, the 3rd one keeps the digits in the positions of 5 to 8, and so on. As another example, the number 2 7464 7392 9274 1937 4643 is represented as

You may use the following template for the Java classes:
class MyBigInteger
{
IntegerNode sign; // reference to the sign node
}
class IntegerNode
{
int digits; // 4 digits in the current node
IntegerNode higher_positions; // digits in the higher positions
}
Programming Tasks:
1) Writing a constructor for the Java class MyBigInteger:
MyBigInteger(long n)
It transforms the given long integer to our singly linked list representation.
2) Writing another constructor for the Java class MyBigInteger:
MyBigInteger(String n)
It transforms the given string-represented integer to our singly linked list representation.
3) Overload the member function toString in the Java class MyBigInteger such that it returns a reference of the string representation of the integer number, and can be used for displaying the number.
4) Overload the member function equals in the Java class MyBigInteger such that you are able to check the equivalence of two big integers represented by singly linked lists.
You are allowed to add auxiliary or helper functions, however please only do so if it is necessary. Some of the programming tasks can be done easily using recursion. The score of your implementation will be determined by the percentage of the passed test cases which are unknown to you.
////////////////////////////////////////MY CODE//////////////////////////////(obviously not correct)
/* MyBigInteger class */ class MyBigInteger { IntegerNode sign; // reference to the sign node
// constructor 1 public MyBigInteger(long n) { if (n 0) { curr.digits = (int)(n % 10000); n /= 10000; if (n > 0) { curr.higher_positions = new IntegerNode(0); curr = curr.higher_positions; } } this.sign.higher_positions = head; }
// constructor 2 public MyBigInteger(String n) { if (n.charAt(0) == '-') { this.sign = new IntegerNode(-1); n = n.substring
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
