Help, does recursive function mean "constant extra space"?


  • 0
    I
    class Solution {
    public:
        void connect(TreeLinkNode *root) {
            if(!root)
    			return;
    		if(root -> left)
    			assist( root -> left, root -> right);
    		connect(root -> left);
    		connect(root -> right);
        }
    	void assist(TreeLinkNode *a, TreeLinkNode *b)
    	{
    		a -> next = b;
    		if(a -> right)
    			assist(a -> right, b ->left);
    	}
    };

  • 0
    D

    I don't think so, because there is underlying call stack


  • 0
    H

    I agree. What's more, Our purpose is not just solving these problem, but learning more.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.