Challenge: Insertion

Let’s insert an integer into a BST.

Problem

Insert an integer into a binary search tree.

Input

A BST and an integer.

Output

A binary search tree with a new value.

Sample input

6 
4
2
5 
1 
3 
8 
7 
9 
10

Sample output

Get hands-on with 1400+ tech skills courses.