Skip to content

Instantly share code, notes, and snippets.

@Who828
Last active August 29, 2015 14:05
Show Gist options
  • Save Who828/6f4450289c8cf4812f83 to your computer and use it in GitHub Desktop.
Save Who828/6f4450289c8cf4812f83 to your computer and use it in GitHub Desktop.
6
4 7
2 5 10
insert(9)
new_root node (6)
go right as val greater then 6
(create a new node for 6)
also point new_root to 4 (left side)
go right as val greater then 7
(create a new node for 7)
No need to point to left side as already null
go left as val less then 10
(create a new node for 10)
assign new val there.
return new_root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment