Insert into a binary tree

If elements 74 , 64 , 93 , 69 , 68 , 90 74, 64, 93, 69, 68, 90 are inserted into an empty binary search tree (BST) in that sequence, what is the element in the lowest level?


The answer is 68.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Apurv Hajare
Mar 28, 2019

remember => node.left < node.data < node.right

now, start drawing tree-->

  • step 1: take 1st value 74 put it in the root node
  • 2 : take 2nd value 64, put it in the left node of root (since 64<74)
  • 3 : 3rd value 93 put it in the right node of root (since 93 > 74)
  • 4 : 4rth value 69 --> correct place is right node of 64 (tricky part to understand)

  • 5 : 68 goes to left node of 69, (we can't put it in the left of 64)

  • 6 : 90 to left node of 93
Shounak Ghosh
Jan 13, 2019

We simply construct the tree using the fact that node.left < node.data < node.right, which gives us an answer of 68.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...