Link up

What will the function below output when it is run on the following linked list \[a : -3\rightarrow-2\rightarrow-1 \rightarrow 0 \rightarrow 1 \rightarrow 2 \rightarrow 3 \rightarrow 4 \rightarrow 5 \]

1
2
3
4
5
6
7
8
def fun2(node):
    if node == None:
        return 1
    funny = 1
    if node.next != None:
        funny = funny * fun2( node.next.next )
    funny *= node.data
    return funny

Details and Assumptions

  • In other words, what is the output of print fun2(a)?
×

Problem Loading...

Note Loading...

Set Loading...