samedkocyigit / interview-questions

0 stars 0 forks source link

Binary Search Tree from Array #18

Open furkankocyigit opened 1 year ago

furkankocyigit commented 1 year ago

Given a sorted (increasing order) array with unique integer elements, write an algorithm to create a binary search tree with minimal height.

Ex: input array {1, 3, 6, 8, 10, 12, 14, 18, 22}

Expected BST:

Image

Locations do not have to be exactly the same in the example but should be something really similar

samedkocyigit commented 1 year ago

should the binary search tree look like as in the your comment or

Image

something like this?

furkankocyigit commented 1 year ago

Printing methodology does not matter, but it should be balanced an depth should be minimum.

furkankocyigit commented 1 year ago

Why did you close this? Did you finish the task and open the PR?