logo

Crowdly

What does this function do? Assume that for any node , node.item will be less...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

What does this function do? Assume that for any node, node.item will be less than or equal to all items in node.link. [2.5 marks]

State and explain the best case complexity of this function [2.5 marks]

def mystery(node1: Node[int], node2: Node[int]):

    if node1 is None: 

        return node2

    if node2 is None:

        return node1

    if node1.item <= node2.item:

        node1.link = mystery(node1.link, node2)

        return node1

    else:

        node2.link = mystery(node1, node2.link)

        return node2

More questions like this

Want instant access to all verified answers on learning.monash.edu?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!