Intuition
The process of converting a binary string/number to an integer with base 10 is a recursive sub-process and so in a linked list.
So we aim at designing a recursive function that adds up to a integer by raising 2 to the current list node value if it’s 1 else 0.
We also have a size
function that gives us the total size of the linked list.
Code
Python3
Big O Analysis
-
Runtime
The runtime complexity here is since we would be processing each node of the list atleast once.
-
Memory
The memory usage is since we are doing recursion so that’s one function call in the stack memory for every node.
— A