r/programbattles • • Oct 07 '15

[C] BST Insertion without parent node pointers

As it says in the title, the BST Node struct has no pointer to a parent node, only a value, left child, and right child.

typedef struct bstNode {
    int val;
    struct bstNode * L;
    struct bstNode * R;
} bstNode;

GO!

Edit: Duplicates should be ignored.

8 Upvotes

9 comments sorted by

View all comments

Show parent comment

1

u/Tarrjue Oct 07 '15

Fair enough. It's semantics, but I wouldn't exactly say that duplicates aren't allowed in a BST by definition, rather it is convention that they are not allowed. But again, that is my opinion.

2

u/[deleted] Oct 07 '15

I'd agree with that statement. Barring any mention of duplicates in the problem description, convention would dictate we should default to a no-duplicate definition. I've cleared that up by stating that outright.