CSC301: Put: Get to the right place [13/30] Previous pageContentsNext page

    public void putLeft (int key) {
        if (root==null) {
            root = new Node (key);
        } else {
            Node x = root;
            while (x.left != null) {
                x = x.left;
            }
            x = new Node (key);
        }
    }

Is this correct?

Previous pageContentsNext page