Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inserting a value vs. a *Node #81

Closed
jutkko opened this issue Feb 25, 2017 · 1 comment
Closed

Inserting a value vs. a *Node #81

jutkko opened this issue Feb 25, 2017 · 1 comment

Comments

@jutkko
Copy link

jutkko commented Feb 25, 2017

Hi I love this repo! I am going through it and I have a question to ask. Here https://github.com/gyuho/learn/blob/master/doc/binary_search_tree/code/00_insert.go#L62, why did you choose to make the insert function take a *Node? Since the pointer to the element can be changed, wouldn't this break the binary search tree?

@gyuho
Copy link
Owner

gyuho commented Feb 25, 2017

Because every node in binary tree is pointer in my implementation.
You could implement it just by passing value (int, string, etc.).
If you concern about manipulating the node before inserting, you can change
your implementation to value :)

@gyuho gyuho closed this as completed Feb 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants