Java Data Structure #4
What I’ve Learned
LL: Binary to Decimal Review
Solution
I solved by not seeing the hints or solutions. Multiplying 2 to calculate the binary value is a great idea. I need to keep this in mind.
public int binaryToDecimal(){
int num = 0;
Node temp = head;
while(temp != null){
num = num * 2 + temp.value;
temp = temp.next;
}
return num;
}